main = do
  getLine
  a <- map read . words <$> getLine
  let ans = solve a
  if ans > 10^18 then print (-1) else print ans

solve :: [Integer] -> Integer
solve [i] = i
solve a = solve la * solve ra
  where n = length a `div` 2
        (la,ra) = splitAt n a


