import Control.Monad
import Data.Array.IO
import Data.IORef

main = do
  n <- readLn :: IO Int
  as <- getLine >>= return . map read . words :: IO [Int]

  memo <- newArray (1,n) 0 :: IO (IOUArray Int Int)
  double_pos <- newIORef (0,0) :: IO (IORef (Int,Int))

  forM_ (zip [1..n+1] as) $ \(i,a) -> do
    m <- readArray memo a
    if m >= 1 then
      writeIORef double_pos (m, i)
      else
      writeArray memo a i
        
  (fs, sn) <- readIORef double_pos 

  let rl = (fs-1) + (n+1-sn)

  var1 <- newIORef 1 :: IO (IORef Integer)
  var2 <- newIORef 1 :: IO (IORef Integer)

  forM_ [1..n+1] $ \k -> do
    modifyIORef var1 (\x -> (x * div_modp (fromIntegral $ n+2-k) (fromIntegral k) (10^9+7)) `mod` (10^9+7))
    if k == 1 then
      return ()
      else if rl + 1 - k < 0 then
      writeIORef var2 0
      else
      modifyIORef var2 (\x -> (x * div_modp (fromIntegral $ rl+1-k) (fromIntegral $ k-1) (10^9+7)) `mod` (10^9+7))
      

    print =<< do
      a1 <- readIORef var1
      a2 <- readIORef var2
      return $ a1 - a2
    
  where
    factorial n
      | n <= 1 = 1 
      | otherwise = n * factorial (n-1)
      
    combination n k
      | k > n = 0
      | k == 0 = 1
      | otherwise = ((div_modp n k (10^9+7)) * (combination (n-1) (k-1))) `mod` (10^9+7)

    div_modp a b m = (a * (power_modp b (m-2) m)) `mod` m

    power_modp a 0 m = 1
    power_modp a 1 m = a `mod` m
    power_modp a p m = ((power'^2 `mod` m) * (if mod p 2 == 0 then 1 else a)) `mod` m
      where power' = power_modp a (div p 2) m  