N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.
n = int(input())
vals = list(map(int, input().split()))

ma = vals[0]
res = [0 for _ in range(n)]
for i, val in enumerate(vals):
    if val < ma: 
        res[i] = ma - val
    if ma < val:
        ma = val

print(max(res))
n = int(input())
vals = list(map(int, input().split()))

ma = vals[0]
res = [0 for _ in range(n)]
for i, val in enumerate(vals):
    if val < ma: 
        res[i] = ma - val
    if ma < val:
        ma = val

print(sum(res))