n = int(eval(input()))

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

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

ans = 0

for i in range(2**n):

    # test = []

    X, Y = 0, 0

    for j in range(n):

        if (i >> j) & 1 == 1:

            X += v[j]

            Y += c[j]

            # test.append([v[j], c[j]])

    if ans < X - Y:

        ans = X - Y

    # print(test)



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

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

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

ans = 0

for vi, ci in zip(v, c):

    if vi >= ci:

        ans += vi - ci



print(ans)
n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    # test = []
    X, Y = 0, 0
    for j in range(n):
        if (i >> j) & 1 == 1:
            X += v[j]
            Y += c[j]
            # test.append([v[j], c[j]])
    if ans < X - Y:
        ans = X - Y
    # print(test)
print(ans)

n = int(eval(input()))
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for vi, ci in zip(v, c):
    if vi >= ci:
        ans += vi - ci
print(ans)

-for i in range(2**n): -    # test = [] -    X, Y = 0, 0 -    for j in range(n): -        if (i >> j) & 1 == 1: -            X += v[j] -            Y += c[j] -            # test.append([v[j], c[j]]) -    if ans < X - Y: -        ans = X - Y -    # print(test) +for vi, ci in zip(v, c): +    if vi >= ci: +        ans += vi - ci