import Data.List
main=do
    n<-readLn::IO Int
    as<-map read.words<$>getLine::IO[Int]
    print $ maximum $ take 100000 $ map (f as) [max 0 (fl as-100000)..]

f as m = sum $ map (\a-> m`mod`a) as
fl as = foldl1 lcm as