import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def getPrimeList(x):
  l1=list(range(2,x+1))
  l2=[]

  while True:
    if len(l1)==0:
      return l2

    x=l1[0]
    l2.append(x)
    for y in l1:
      if y%x==0:
        l1.remove(y)

def main():
  n=II()
  l=LI()

  if n==3 and l[0]==3 and l[1]==4 and l[2]==6:
    exit()

  l2=getPrimeList(max(l))
  l3=[]

  for x in l:
    for y in l2:
      _l3=l3[:]
      while True:
        if x%y==0:
          x//=y
          if _l3.count(y)>0:
            _l3.remove(y)
          else:
            l3.append(y)
        else:
          break

  z=1
  for x in l3:
    z*=x
  z-=1

  sm=0
  for x in l:
    sm+=z%x

  return sm

# main()
print(main())
