n=int(eval(input()))



h=[int(x) for x in input().split()]



height=[]



result=0

tmp=0



for i in range(max(h)):

    buf=[]

    for j in range(n):

        if h[j] > i:

            buf.append(1)

        else:

            buf.append(0)

    height.append(buf)



for val in height:

    while(tmp < len(val)):

        if val[tmp]==0:

            tmp+=1

        else:

            result+=1

            while(tmp<len(val)):

                if(val[tmp]==0):

                    break

                tmp+=1;

    tmp=0

#print(height)

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

h=[int(x) for x in input().split()]

buf=[0 for i in range(n)]



ans=0



flag=False



for i in range(max(h)):

    for j in range(n):

        if h[j] >= i+1:

            flag=True

        if flag and h[j] <= i:

            ans+=1

            flag=False

    if flag:

        ans+=1

        flag=False



print(ans)
n = int(eval(input()))
h = [int(x) for x in input().split()]
height = []
result = 0
tmp = 0
for i in range(max(h)):
    buf = []
    for j in range(n):
        if h[j] > i:
            buf.append(1)
        else:
            buf.append(0)
    height.append(buf)
for val in height:
    while tmp < len(val):
        if val[tmp] == 0:
            tmp += 1
        else:
            result += 1
            while tmp < len(val):
                if val[tmp] == 0:
                    break
                tmp += 1
    tmp = 0
# print(height)
print(result)

n = int(eval(input()))
h = [int(x) for x in input().split()]
buf = [0 for i in range(n)]
ans = 0
flag = False
for i in range(max(h)):
    for j in range(n):
        if h[j] >= i + 1:
            flag = True
        if flag and h[j] <= i:
            ans += 1
            flag = False
    if flag:
        ans += 1
        flag = False
print(ans)

-height = [] -result = 0 -tmp = 0 +buf = [0 for i in range(n)] +ans = 0 +flag = False -    buf = [] -        if h[j] > i: -            buf.append(1) -        else: -            buf.append(0) -    height.append(buf) -for val in height: -    while tmp < len(val): -        if val[tmp] == 0: -            tmp += 1 -        else: -            result += 1 -            while tmp < len(val): -                if val[tmp] == 0: -                    break -                tmp += 1 -    tmp = 0 -# print(height) -print(result) +        if h[j] >= i + 1: +            flag = True +        if flag and h[j] <= i: +            ans += 1 +            flag = False +    if flag: +        ans += 1 +        flag = False +print(ans)