n = gets.to_i
c = n.times.map {gets.to_i}
M = 10 ** 9 + 7
m = Array.new(2 * 10 ** 5 + 1)
m[c[-1]] = 1

(n-2).downto(0) do |i|
    x, y = c[i], c[i+1]
    next if x == y
    m[x] = m[x] ? (m[x] + m[y]) % M : m[y]
end
#p m[0..5]
p m[c[0]]