N, *C = $<.read.split.map(&:to_i)

C << 0
s, i, h = [nil]*N+[0,1], -1, Hash.new(-2)
until (i+=1) == N
	next s[i] = s[i-1] if C[i] == C[i-1]
	s[i] = (s[i-1] + s[h[C[i]]]) % 1000000007
	h[C[i]] = i
end
p s[N-1]
