Mod = 10**9 + 7

N = gets.to_i
 
s = gets.chomp
(N-1).times do |i|
  c = gets.chomp
  next if s[-1] == c
  s += c
end
 
# p s
 
h = Hash.new( nil )
 
n = s.size
dp = Array.new( n + 1 , nil )
 
dp[0] = 1
 
(0...n).each do |i|
  c = s[i]
  
  if h[c] && dp[h[c]]
    dp[i+1] = ( dp[i] + dp[h[c]] ) % Mod
  else
    dp[i+1] = dp[i] 
  end
  h[c] = i
  
  # p [dp, cnt[0,7]]
end
 
# p dp
p dp[-1]