n = int(eval(input()))

R = []

for i in range(n):

    R.append(int(eval(input())))



# R???i???????????§???????°???????i?????????????´???¨???????????????list

mins = [R[0]]

for i in range(1, n):

    mins.append(min(R[i], mins[i-1]))



# ???????????????j????????????????????\??????????°??????¨??????????±?????????????????????§???????±????????????????

mx = - 10 ** 12

for j in range(1, n):

    mx = max(mx, R[j] - mins[j-1])



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



# R[0]

minv = int(eval(input()))

maxv = - 10 ** 10



# R[1..N-1]

for j in range(1, n):

    r = int(eval(input()))

    maxv = max(maxv, r - minv)

    minv = min(minv, r)



print(maxv)
n = int(eval(input()))
R = []
for i in range(n):
    R.append(int(eval(input())))
# R???i???????????§???????°???????i?????????????´???¨???????????????list
mins = [R[0]]
for i in range(1, n):
    mins.append(min(R[i], mins[i - 1]))
# ???????????????j????????????????????\??????????°??????¨??????????±?????????????????????§???????±????????????????
mx = -(10**12)
for j in range(1, n):
    mx = max(mx, R[j] - mins[j - 1])
print(mx)

n = int(eval(input()))
# R[0]
minv = int(eval(input()))
maxv = -(10**10)
# R[1..N-1]
for j in range(1, n):
    r = int(eval(input()))
    maxv = max(maxv, r - minv)
    minv = min(minv, r)
print(maxv)

-R = [] -for i in range(n): -    R.append(int(eval(input()))) -# R???i???????????§???????°???????i?????????????´???¨???????????????list -mins = [R[0]] -for i in range(1, n): -    mins.append(min(R[i], mins[i - 1])) -# ???????????????j????????????????????\??????????°??????¨??????????±?????????????????????§???????±???????????????? -mx = -(10**12) +# R[0] +minv = int(eval(input())) +maxv = -(10**10) +# R[1..N-1] -    mx = max(mx, R[j] - mins[j - 1]) -print(mx) +    r = int(eval(input())) +    maxv = max(maxv, r - minv) +    minv = min(minv, r) +print(maxv)