n = int(eval(input()))

x = []

for i in range(n):

    x.append(int(eval(input())))



imin=0

imax=1

maxVal=x[imax]-x[imin]

for i in range(1,n):

    if x[imin] > x[i]:

        imin=i

        imax=i+1

        if imax > n-1:

            break

        dx = x[imax]-x[imin]

        if maxVal < dx:

            maxVal = dx

    elif x[imax] < x[i]:

        imax = i

        dx = x[imax]-x[imin]

        if maxVal < dx:

            maxVal = dx

print(maxVal)



n = int(eval(input()))

maxVal = -2000000000

minVal = int(eval(input()))

for i in range(1,n):

    x=int(eval(input()))

    dx = x-minVal

    if maxVal < dx:

        maxVal = dx

    if minVal > x:

        minVal = x

print(maxVal)

n = int(eval(input()))
x = []
for i in range(n):
    x.append(int(eval(input())))
imin = 0
imax = 1
maxVal = x[imax] - x[imin]
for i in range(1, n):
    if x[imin] > x[i]:
        imin = i
        imax = i + 1
        if imax > n - 1:
            break
        dx = x[imax] - x[imin]
        if maxVal < dx:
            maxVal = dx
    elif x[imax] < x[i]:
        imax = i
        dx = x[imax] - x[imin]
        if maxVal < dx:
            maxVal = dx
print(maxVal)

n = int(eval(input()))
maxVal = -2000000000
minVal = int(eval(input()))
for i in range(1, n):
    x = int(eval(input()))
    dx = x - minVal
    if maxVal < dx:
        maxVal = dx
    if minVal > x:
        minVal = x
print(maxVal)

-x = [] -for i in range(n): -    x.append(int(eval(input()))) -imin = 0 -imax = 1 -maxVal = x[imax] - x[imin] +maxVal = -2000000000 +minVal = int(eval(input())) -    if x[imin] > x[i]: -        imin = i -        imax = i + 1 -        if imax > n - 1: -            break -        dx = x[imax] - x[imin] -        if maxVal < dx: -            maxVal = dx -    elif x[imax] < x[i]: -        imax = i -        dx = x[imax] - x[imin] -        if maxVal < dx: -            maxVal = dx +    x = int(eval(input())) +    dx = x - minVal +    if maxVal < dx: +        maxVal = dx +    if minVal > x: +        minVal = x