{-# LANGUAGE BangPatterns #-}
import Prelude hiding (getLine, getContents, words, lines)
import Data.ByteString.Char8 as BC hiding (sort, map, length, head, tail)
import Data.List hiding (words)
import Data.Maybe

modulo :: Int
modulo = 1000000007

powModM :: Int -> Int -> Int
powModM base power = pmm' power 1
    where
        base' = base `mod` modulo
        pmm' 0 acc = acc
        pmm' !p !acc = pmm' (p-1) ((base' * acc) `mod` modulo)

isSane :: [Int] -> Bool
isSane [] = True
isSane l = if head l == 0
              then isSane' 2 (tail l)
              else isSane' 1 l
    where
        isSane' :: Int -> [Int] -> Bool
        isSane' _ [] = True
        isSane' _ [_] = False
        isSane' n (h0:h1:r) = (h0 == n && h1 == n) && isSane' (n+2) r
 
readReport :: IO [Int]
readReport = sort . parse <$> getLine
    where
        parse = map unsafeReadInt . words

unsafeReadInt :: ByteString -> Int
unsafeReadInt = fst . fromJust . readInt

solve ::  [Int] -> Int
solve v = if isSane v
             then powModM 2 $ length v `div` 2
             else 0

main = do
    _ <- getLine
    readReport >>= print . solve