import Data.List (foldl')

main = do
  _ <- getLine
  a <- map read . words <$> getLine

  let l = binarySearch ((>=2) . foo a) 0 (10^18)
  let r = binarySearch ((>=3) . foo a) 0 (10^18)

  if l < r then putStrLn $ show l ++ " " ++ show (r - 1)
           else print (-1)

foo :: [Int] -> Int -> Int
foo a x = foldl' (\a b -> a `div` b * b) x a

binarySearch :: (Int -> Bool) -> Int -> Int -> Int
binarySearch f l r
  | r - l == 1 = r
  | otherwise = let m = div (l + r) 2
                in if f m then binarySearch f l m
                          else binarySearch f m r

