N = int(eval(input()))



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



flowers = [0] * N



start = 0

end = 0



con = 0



while flowers != H:

	for i in range(0,N):

		if H[i] > flowers[i]:

			start = i

			for j in range(i,N):

				if H[j] == flowers[j]:

					end = j

					break

				else:

					end = N

			break





	for k in range(start,end):

		flowers[k] += 1

	con += 1

	start = 0

	end = 0

	

	





print(con)
N = int(eval(input()))

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

s = L[0]

ans = s

for i in range(0,N):

  if s <= L[i]:

    ans += L[i] - s

  s = L[i]



print(ans)
N = int(eval(input()))
H = list(map(int, input().split()))
flowers = [0] * N
start = 0
end = 0
con = 0
while flowers != H:
    for i in range(0, N):
        if H[i] > flowers[i]:
            start = i
            for j in range(i, N):
                if H[j] == flowers[j]:
                    end = j
                    break
                else:
                    end = N
            break
    for k in range(start, end):
        flowers[k] += 1
    con += 1
    start = 0
    end = 0
print(con)

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

-H = list(map(int, input().split())) -flowers = [0] * N -start = 0 -end = 0 -con = 0 -while flowers != H: -    for i in range(0, N): -        if H[i] > flowers[i]: -            start = i -            for j in range(i, N): -                if H[j] == flowers[j]: -                    end = j -                    break -                else: -                    end = N -            break -    for k in range(start, end): -        flowers[k] += 1 -    con += 1 -    start = 0 -    end = 0 -print(con) +L = list(map(int, input().split())) +s = L[0] +ans = s +for i in range(0, N): +    if s <= L[i]: +        ans += L[i] - s +    s = L[i] +print(ans)