{-# LANGUAGE TypeApplications #-}
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

bsToInt :: BS.ByteString -> Int
bsToInt = fst . fromJust . BS.readInt

main :: IO ()
main = do
 n <- bsToInt <$> BS.getLine
 as <- map (read @Int . BS.unpack) . BS.words <$> BS.getLine
 print $ loop (sort as) 1
   where
     loop as n
       | n > 10 ^ 18 = -1
       | as == [] = n
       | otherwise = loop (tail as) (n * head as)  