import sys

b,s=-1e10,1e10

eval(input())

for r in map(int,sys.stdin):

 if b<r-s:b=r-s

 if s>r:s=r

print(b)

import sys

s=1e10;b=-s

eval(input())

for r in map(int,sys.stdin):

 if b<r-s:b=r-s

 if s>r:s=r

print(b)

import sys

b, s = -1e10, 1e10
eval(input())
for r in map(int, sys.stdin):
    if b < r - s:
        b = r - s
    if s > r:
        s = r
print(b)

import sys

s = 1e10
b = -s
eval(input())
for r in map(int, sys.stdin):
    if b < r - s:
        b = r - s
    if s > r:
        s = r
print(b)

-b, s = -1e10, 1e10 +s = 1e10 +b = -s