N,*A = `dd`.split.map &:to_i
Mod = 10**9 + 7
dp = Array.new(N+1,0)
dp[0] = 1
h = {}
(1..N).each{ |i|
  a = A[i-1]
  dp[i] = dp[i-1]
  if h[a] && h[a] < i-1
    dp[i] += dp[h[a]]
  end
  dp[i] %= Mod
  h[a] = i
}
p dp[-1]
