import Data.List

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ns <- map (read :: String -> Int) . words <$> getLine
  print $ solve ns n

solve :: [Int] -> Int -> Int
solve ns n = if n `mod` 2 == 0
             then evenFold
             else oddFold
  where
    evenFold = foldl f 1  ans
    oddFold = foldl1 f ans
    ans = map length $ group $ sort ns
    f a b = if b /= 2 then 0
            else a * b `mod` 1000000007
