INF = 2 * 10 ** 5
MOD = 10 ** 9 + 7
n = gets.to_i
colors = []
n.times { colors << gets.to_i }
places = Array.new(INF + 1) { [] }
colors.each_with_index do |color, index|
  places[color] << index
end
dp = [1]
previous = colors.shift
colors.each.with_index(1) do |color, index|
  place_index = places[color].bsearch_index { |place| place >= index }
  if previous == color || place_index == 0
    dp[index] = dp[index - 1]
  else
    dp[index] = dp[index - 1] + dp[places[color][place_index - 1]]
  end
  previous = color
end
puts dp.last % MOD
