module Main where

import Control.Applicative
import Control.Monad

fx :: [Int] -> Int -> Int
fx as m = sum $ fmap (mod m) as

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    print $ fx as (foldr1 lcm as - 1)