from fractions import gcd

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

agcd=gcd(a[0],a[1])
alcm=a[0]*a[1]//agcd
for i in range(n-2):
    agcd=gcd(alcm,a[i+2])
    alcm=alcm*a[i+2]//agcd
    
#print(alcm)
    
if 1==1:
    fmax=0
    for i in range(alcm):
        f=0
        for j in range(n):
            f=f+(i%a[j])
        if f>fmax:
            fmax=f
    print(fmax)