fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readInputLine().toInt()
    
    val dp = LongArray(N)
    dp[0] = 1L
    val lastIndex = IntArray(200001) { -1 }
    
    lastIndex[readInputLine().toInt()] = 0
    
    for (i in 1 until N) {
        val c = readInputLine().toInt()
        if (lastIndex[c] != -1 && i - lastIndex[c] != 1) {
            dp[i] = dp[i - 1] + dp[lastIndex[c]]
            dp[i] %= mod
        } else {
            dp[i] = dp[i - 1]
        }
        lastIndex[c] = i
    }

    println(dp[N - 1])
}

fun readInputLine(): String {
    return readLine()!!
}
