Mod = 10**9 + 7

N = gets.to_i
C = Array.new( N + 1 )
N.times{ |i| C[i] = gets.to_i }

dp = Array.new(N+1,0)
h = {}

dp[0] = 1
(1..N).each do |i|
  
  c = C[i-1]
  dp[i] = dp[i-1]
  
  if h[c] && h[c] < i-1
    dp[i] += dp[h[c]]
  end
  
  dp[i] %= Mod
  h[c] = i
end

p dp[-1]