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

dp = Array.new(N + 1, 0)
dp[0] = 1
pos = Hash.new

C.each_with_index do |c, idx|
  dp[idx + 1] = dp[idx]

  if pos[c] && pos[c] != idx - 1
    pattern_cnt = dp[pos[c] + 1]
    dp[idx + 1] = (dp[idx + 1] + pattern_cnt) % MOD
  end

  pos[c] = idx
end

puts dp[N]
