N = eval(input())

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



summ = 1

for i in a:

    summ *= i



summ2 = 0

for i in a:

    summ2 += (summ-1)% i



print(summ2)
N = eval(input())

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



summ2 = sum(a) - int(N)



print(summ2)
N = eval(input())
a = list(map(int, input().split()))
summ = 1
for i in a:
    summ *= i
summ2 = 0
for i in a:
    summ2 += (summ - 1) % i
print(summ2)

N = eval(input())
a = list(map(int, input().split()))
summ2 = sum(a) - int(N)
print(summ2)

-summ = 1 -for i in a: -    summ *= i -summ2 = 0 -for i in a: -    summ2 += (summ - 1) % i +summ2 = sum(a) - int(N)