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())
A = input().split()
# print(A)
A_list = list(map(float, A))
sa = 0
for i in range(N-1):
    # print(i)
    if A_list[i] > A_list[i+1]:
        sa += A_list[i] - A_list[i+1]
        A_list[i+1] = A_list[i]
print(sa)

N = int(input())
A = input().split()
# print(A)
A_list = list(map(float, A))
sa = 0
for i in range(N-1):
    # print(i)
    if A_list[i] > A_list[i+1]:
        sa += A_list[i] - A_list[i+1]
        A_list[i+1] = A_list[i]
print(int(sa))
