import fractions



def lcm(a,b):

    return (a*b)//fractions.gcd(a,b)



N=int(eval(input()))

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

tmp=a[0]

for i in range(1,N):

    tmp=lcm(tmp,a[i])

tmp-=1

ans=0

for i in range(N):

    ans+=tmp%a[i]

print(ans)
N=int(eval(input()))

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

ans=0

for i in range(N):

    ans+=a[i]-1

print(ans)
import fractions


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


N = int(eval(input()))
a = list(map(int, input().split()))
tmp = a[0]
for i in range(1, N):
    tmp = lcm(tmp, a[i])
tmp -= 1
ans = 0
for i in range(N):
    ans += tmp % a[i]
print(ans)

N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += a[i] - 1
print(ans)

-import fractions - - -def lcm(a, b): -    return (a * b) // fractions.gcd(a, b) - - -tmp = a[0] -for i in range(1, N): -    tmp = lcm(tmp, a[i]) -tmp -= 1 -    ans += tmp % a[i] +    ans += a[i] - 1