N = gets.to_i
col = [0]*(N+1)
dp = [0]*(N+1)
dp[0] = 1
pc = 0
N.times do |i|
  c = gets.to_i
  if c == pc
    dp[i+1] = dp[i]
  else
    dp[i+1] = dp[i] + col[c]
    col[c] += dp[i]
  end
  pc = c
end
p dp[N]