#coding:utf-8

n = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
    return (a * b) // gcd(a, b)

def func(x, A):
    ans = 0
    for y in A:
        ans += x%y
    return ans

def hoge(A):
    B = []
    for i in range(len(A)-1):
        for j in range(len(A)-i-1):
            tmp = lcm(A[i], A[i+1+j])
            if tmp not in B: B.append(tmp)
    return B

max_lcm = 0
B = []
for i in range(n-1):
    for j in range(n-i-1):
        tmp = lcm(A[i], A[i+1+j])
        if tmp not in B: B.append(tmp)

while(len(B) > 1):
    B = hoge(B)

print(func(B[0]-1, A))
