n = int(eval(input()))

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



ans = 0

hk = 0

for i in range(n):

    if hk == h[i]:

        continue

    elif hk < h[i]:

        while hk < h[i]:

            hk += 1

            ans += 1

    elif hk > h[i]:

        while hk > h[i]:

            hk -= 1

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

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

ans = hk = 0

for i in range(n):

    if hk < h[i]:

        ans += h[i] - hk

    hk = h[i]

print(ans)
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 0
hk = 0
for i in range(n):
    if hk == h[i]:
        continue
    elif hk < h[i]:
        while hk < h[i]:
            hk += 1
            ans += 1
    elif hk > h[i]:
        while hk > h[i]:
            hk -= 1
print(ans)

n = int(eval(input()))
h = list(map(int, input().split()))
ans = hk = 0
for i in range(n):
    if hk < h[i]:
        ans += h[i] - hk
    hk = h[i]
print(ans)

-ans = 0 -hk = 0 +ans = hk = 0 -    if hk == h[i]: -        continue -    elif hk < h[i]: -        while hk < h[i]: -            hk += 1 -            ans += 1 -    elif hk > h[i]: -        while hk > h[i]: -            hk -= 1 +    if hk < h[i]: +        ans += h[i] - hk +    hk = h[i]