N = int(eval(input()))

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



current_h = [0] * N

c = 0



l = 0

while True:

    escape_loop = False

    while current_h[l] == h[l]:

        if l + 1 < N:

            l += 1

        else:

            escape_loop = True

            break

    if escape_loop:

        break



    r = l

    while True:

        if r + 1 < N and current_h[r + 1] < h[r + 1]:

            r += 1

        else:

            break



    for i in range(l, r + 1):

        current_h[i] += 1

    c += 1



print(c)

N = int(eval(input()))

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



s = h[0]

for i in range(1, N):

    s += max(0, h[i] - h[i - 1])



print(s)

N = int(eval(input()))
h = list(map(int, input().split()))
current_h = [0] * N
c = 0
l = 0
while True:
    escape_loop = False
    while current_h[l] == h[l]:
        if l + 1 < N:
            l += 1
        else:
            escape_loop = True
            break
    if escape_loop:
        break
    r = l
    while True:
        if r + 1 < N and current_h[r + 1] < h[r + 1]:
            r += 1
        else:
            break
    for i in range(l, r + 1):
        current_h[i] += 1
    c += 1
print(c)

N = int(eval(input()))
h = list(map(int, input().split()))
s = h[0]
for i in range(1, N):
    s += max(0, h[i] - h[i - 1])
print(s)

-current_h = [0] * N -c = 0 -l = 0 -while True: -    escape_loop = False -    while current_h[l] == h[l]: -        if l + 1 < N: -            l += 1 -        else: -            escape_loop = True -            break -    if escape_loop: -        break -    r = l -    while True: -        if r + 1 < N and current_h[r + 1] < h[r + 1]: -            r += 1 -        else: -            break -    for i in range(l, r + 1): -        current_h[i] += 1 -    c += 1 -print(c) +s = h[0] +for i in range(1, N): +    s += max(0, h[i] - h[i - 1]) +print(s)