import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad 

main :: IO ()
main = readLn >>= main'
    where
        main' n = breads >>= print . solve n . group . sort 

solve :: Int -> [[Int]] -> Int 
solve n (x : xs)
    | head x == 0 && length x == 1 = check 2 xs
    | head x == 1 && length x == 2 = modf $ 2 * check 3 xs
    | otherwise = 0
    where
        check i (y : ys)
            | head y == i && length y == 2 = modf $ 2 * check (i + 2) ys
            | otherwise = 0
        check _ _ = 1

modf :: Int -> Int
modf = (`mod` 1000000007)

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)