n=eval(input())

a=[int(i) for i in input().split()]

ac=a[:]





def lcm(x, y):

    x2=x

    y2=y

    while y != 0:

        x, y = y, x%y

    return (x2 * y2) // x



while(len(ac)>1):

    x=ac.pop()

    y=ac.pop()

    ac.append(lcm(x, y))



g=ac[0]-1



ans=0

for i in a:

    ans+=g%i



print(ans)

[n]=[int(i) for i in input().split()]

li=[int(i) for i in input().split()]



#print(li)



ans=0

for i in li:

    ans+=i



print((ans-n))
n = eval(input())
a = [int(i) for i in input().split()]
ac = a[:]


def lcm(x, y):
    x2 = x
    y2 = y
    while y != 0:
        x, y = y, x % y
    return (x2 * y2) // x


while len(ac) > 1:
    x = ac.pop()
    y = ac.pop()
    ac.append(lcm(x, y))
g = ac[0] - 1
ans = 0
for i in a:
    ans += g % i
print(ans)

[n] = [int(i) for i in input().split()]
li = [int(i) for i in input().split()]
# print(li)
ans = 0
for i in li:
    ans += i
print((ans - n))

-n = eval(input()) -a = [int(i) for i in input().split()] -ac = a[:] - - -def lcm(x, y): -    x2 = x -    y2 = y -    while y != 0: -        x, y = y, x % y -    return (x2 * y2) // x - - -while len(ac) > 1: -    x = ac.pop() -    y = ac.pop() -    ac.append(lcm(x, y)) -g = ac[0] - 1 +[n] = [int(i) for i in input().split()] +li = [int(i) for i in input().split()] +# print(li) -for i in a: -    ans += g % i -print(ans) +for i in li: +    ans += i +print((ans - n))