import Control.Monad
import Control.Applicative

f :: Int -> [Int] -> Int
f _ []     = 0
f m (x:xs) = m `mod` x + f m xs

solver :: [Int] -> Int
solver xs = f (m-1) xs
    where m = foldl lcm 1 xs

main :: IO ()
main = do
    _ <- getLine
    s <- (map read) . words <$> getLine
    print (solver s)
