import fractions

from functools import reduce

def lcm_base(x, y):

    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):

    return reduce(lcm_base, numbers, 1)

n=int(eval(input()))

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

m=lcm(*numbers)-1

ans=0

for i in range(n):

    ans+=m%numbers[i]

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

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

ans=0

for i in range(n):

    ans+=numbers[i]-1

print(ans)
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n = int(eval(input()))
numbers = list(map(int, input().split()))
m = lcm(*numbers) - 1
ans = 0
for i in range(n):
    ans += m % numbers[i]
print(ans)

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

-import fractions -from functools import reduce - - -def lcm_base(x, y): -    return (x * y) // fractions.gcd(x, y) - - -def lcm(*numbers): -    return reduce(lcm_base, numbers, 1) - - -m = lcm(*numbers) - 1 -    ans += m % numbers[i] +    ans += numbers[i] - 1