import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let o | odd n  = (== sort as) . (0 :) $ concatMap (replicate 2) (take (n `div` 2) [2,4..])
          | even n = (== sort as) $ concatMap (replicate 2) (take (n `div` 2) [1,3..])
    print $ if o then powerMod 2 (n `div` 2) else 0

moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

mulMod x y = modN $ x * y

powerMod x 0 = 1
powerMod x y
    | even y = mulMod t t
    | otherwise = mulMod x $ mulMod t t
    where
        t = powerMod x $ div y 2