import math


class Sieve:
    """Sieve of Eratosthenes.

    List primes up to n.
    """

    def __init__(self, n):
        self.__prime = []
        self.__is_prime = [i >= 2 for i in range(n + 1)]

        for i in range(2, int(math.sqrt(n)) + 1):
            if self.__is_prime[i]:
                for j in range(i * i, n + 1, i):
                    self.__is_prime[j] = False

        for i in range(2, n + 1):
            if self.__is_prime[i]:
                self.__prime.append(i)

    def prime(self):
        return self.__prime

    def is_prime(self, n):
        return self.__is_prime[n]


if __name__ == '__main__':
    N = int(input())  # 2 <= N <= 3000
    a = list(map(int, input().split()))  # 2 <= ai <= 100000
    b = [ai for ai in a]

    p = Sieve(100000).prime()  # len = 9952

    prime_to_power = [0 for _ in range(p[-1] + 1)]
    for i in range(len(a)):
        for prime in p:
            power = 0
            while b[i] % prime == 0:
                b[i] /= prime
                power += 1
            prime_to_power[prime] = max(prime_to_power[prime], power)

    lcm = 1
    for i in range(len(prime_to_power)):
        lcm *= i ** prime_to_power[i]
    m = lcm - 1
    ans = 0
    for ai in a:
        ans += m % ai
    print(ans)
