{-# LANGUAGE BangPatterns #-}

import Data.Array
import qualified Data.ByteString.Char8 as C
import Data.Maybe
import qualified Data.Vector.Unboxed as V

main = sol <$> readLn <*> get >>= put

get = V.unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

put = mapM_ (putStrLn . show)

sol n v = f <$> [1..n+1]
  where
  h = V.unsafeAccumulate_ (+) (V.replicate (n+1) 0) v (V.replicate (n+1) 1) :: V.Vector Int
  d = fromJust $ V.elemIndex 2 h
  i = V.elemIndices d v
  m = n-(V.last i-V.head i)
  f k
    | k==1      = Modulo n
    | k==n+1    = Modulo 1
    | k-1<=m    = chs (n+1) k-chs m (k-1)
    | otherwise = chs (n+1) k
  chs n m = fac n m' * inv (fac m' m')
    where 
    m' = min m (n-m)
  fac n m = memo!(n,m)
  bnds = ((0,0),(n+1,n+1))
  memo = listArray bnds $ f2 <$> range bnds
  f2 (i,0) = Modulo 1
  f2 (i,j) = Modulo i*memo!(i-1,j-1)

newtype Modulo = Modulo { getInt :: Int } deriving (Eq, Ord)
p = 10^9+7 :: Int

instance Num Modulo where
  Modulo a + Modulo b = Modulo ((a + b) `mod` p)
  Modulo a - Modulo b = Modulo ((a - b) `mod` p)
  Modulo a * Modulo b = Modulo ((a * b) `mod` p)
  abs = undefined
  signum = undefined
  fromInteger i = Modulo (fromIntegral i `mod` p)

instance Show Modulo where
  show (Modulo i) = show i

inv :: Modulo -> Modulo
inv 1 = 1
inv a = pwr a (p-2)

pwr :: Modulo -> Int -> Modulo
pwr !a !n
  | n == 0    = 1
  | odd n     = a*r
  | otherwise = r
  where
  q = pwr a (n `div` 2)
  r = q*q