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

product=1
for i in range(len(a)):
    product*=a[i]


mods=[]
for i in range(product):
    mods.append(sum([i%a_l for a_l in a]))

ans=max(mods)
print(ans)
