main = do
  getLine
  s <- getLine
  print . foldr (%*%) 3 . g $ f s

f [] = []
f [x] = [1]
f (x:y:zs)
  | x == y = 0 : f zs
  | otherwise = [1, 1] ++ f zs

g [] = []
g [0] = [0]
g (0:0:zs) = g (0:zs)
g (0:1:zs) = 0 : g zs
g [1] = [1]
g (1:0:zs) = g zs
g (1:1:zs) = 1 : g zs

(%*%) x y = x * y `mod` 1000000007 

