N = gets.to_i
C = N.times.map{gets.to_i}
MOD = 10**9+7

left = Array.new(200001, -1)
dp = Array.new(N+1, 0)
dp[0] = 1
N.times do |i|
    dp[i+1] += dp[i]
    c = C[i]
    if left[c] >= 0 && left[c] < i-1
        dp[i+1] += dp[left[c]+1]
    end
    dp[i+1] %= MOD
    left[c] = i
end

puts dp[N]