from functools import reduce

from fractions import gcd





def lcm_base(x, y):

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





def lcm_list(lst):

    return reduce(lcm_base, lst, 1)





n = int(eval(input()))

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

l = lcm_list(lst_a)





ans = sum((l-1) % a for a in lst_a)

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

sum_a = sum(map(int, input().split()))

ans = sum_a - n

print(ans)
from functools import reduce
from fractions import gcd


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


def lcm_list(lst):
    return reduce(lcm_base, lst, 1)


n = int(eval(input()))
lst_a = list(map(int, input().split()))
l = lcm_list(lst_a)
ans = sum((l - 1) % a for a in lst_a)
print(ans)

n = int(eval(input()))
sum_a = sum(map(int, input().split()))
ans = sum_a - n
print(ans)

-from functools import reduce -from fractions import gcd - - -def lcm_base(x, y): -    return (x * y) // gcd(x, y) - - -def lcm_list(lst): -    return reduce(lcm_base, lst, 1) - - -lst_a = list(map(int, input().split())) -l = lcm_list(lst_a) -ans = sum((l - 1) % a for a in lst_a) +sum_a = sum(map(int, input().split())) +ans = sum_a - n