import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  let
    m = 10 ^ 18 :: Int
    go :: Int -> [Int] -> Int
    go _ (0 : _)  = 0
    go 0 (_ : xs) = go 0 xs
    go y (x : xs) | m `div` x < y = go 0 xs
                  | otherwise     = go (y * x) xs
    go 0 _ = -1
    go y _ = y
  T.getLine
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print . go 1 $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
