{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow
import           Data.Bits

main = do
  getLine
  a <- sort . map (read @Int) . words <$> getLine
  print
    $ case
        foldM (((\x -> if x > 10 ^ 18 then Nothing else Just x) .) . (*)) 1 a
      of
        Nothing -> -1
        Just x  -> x
