n = int(eval(input()))

H = [int(i) for i in input().split()]



count = 0

for _ in range(100):

    flag = 1

    for i in range(n):

        if H[i] > 0:

            H[i] -= 1

            if flag:

                count += 1

                flag = 0

        else:

            flag = 1

            

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

A = [0] + [int(i) for i in input().split()]

cnt = 0

for i in range(n):

    if A[i + 1] > A[i]:

        cnt += A[i + 1] - A[i]

print(cnt)
n = int(eval(input()))
H = [int(i) for i in input().split()]
count = 0
for _ in range(100):
    flag = 1
    for i in range(n):
        if H[i] > 0:
            H[i] -= 1
            if flag:
                count += 1
                flag = 0
        else:
            flag = 1
print(count)

n = int(eval(input()))
A = [0] + [int(i) for i in input().split()]
cnt = 0
for i in range(n):
    if A[i + 1] > A[i]:
        cnt += A[i + 1] - A[i]
print(cnt)

-H = [int(i) for i in input().split()] -count = 0 -for _ in range(100): -    flag = 1 -    for i in range(n): -        if H[i] > 0: -            H[i] -= 1 -            if flag: -                count += 1 -                flag = 0 -        else: -            flag = 1 -print(count) +A = [0] + [int(i) for i in input().split()] +cnt = 0 +for i in range(n): +    if A[i + 1] > A[i]: +        cnt += A[i + 1] - A[i] +print(cnt)