n = int(input())
lst = list(map(int, input().split()))
m = int(input())
sum = 0
for i in lst:
if i % m == 0:
sum += i // m
else:
sum += i // m + 1
print(sum * m)
n = int(input())
lst = list(map(int, input().split()))
m = int(input())
sum = 0
for i in lst:
if i % m == 0:
sum += i // m
else:
sum += i // m + 1
print(sum * m)