import numpy as np
N=int(input())
A=[int(x) for x in input().split()]
B=list(set(A))

def gcd(a,b):#最大公約数
  return a if b == 0 else gcd(b,a%b)

g=B[0]
for i in range(len(B)):
  g=gcd(g,B[i])
  

def F(A,x):
  y=0
  for i in range(len(A)):
    y += x%A[i]
  return y

print(F(A,np.prod(B)//g-1))