{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.Char
import Control.Monad
import Control.Monad.ST

solve :: Int -> Int
solve 0 = 1
solve n = mulMod 2 $ solve (n-1)
    where
        mulMod a b = (a * b) `rem` (10^9+7)

search :: VU.Vector Int -> Int -> Bool 
search vec n = runST $ do
    (vec' :: VUM.STVector s Int) <- VUM.replicate n 0
    forM_ [0..n-1] $ \i -> do
        let v = vec VU.! i
        VUM.modify vec' (+1) v 
    vec'' <- VU.unsafeFreeze vec'
    if odd n
        then do
            let step b (i,e) = if i == 0 then (e == 1) && b else if even i then (e == 2) && b else (e == 0) && b
            return $ VU.foldl' step True (VU.zip (VU.fromList [0..n-1]) vec'')
        else do
            let step b (i,e) = if odd i then (e == 2) && b else (e == 0) && b
            return $ VU.foldl' step True (VU.zip (VU.fromList [0..n-1]) vec'')

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ 
        if search xs n
            then solve (n `quot` 2)
            else 0