import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    _  <- fst . fromJust . B.readInt <$> B.getLine
    ns <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let n = (\n -> n-1) . foldr lcm 1 $ ns
    print . sum . map (mod n) $ ns