num = int(input())
minnum = 10 ** 18 + 1
ans = (-10 ** 9 - 1)
for n in range(num):
    newnum = int(input())
    ans = max(ans,newnum - minnum)
    minnum = min(minnum,newnum)
print(ans) num = int(input()) num int(input()) int input() input minnum = 10 ** 18 + 1 minnum 10 ** 18 + 1 10 ** 18 10 18 1 ans = (-10 ** 9 - 1) ans -10 ** 9 - 1 -10 ** 9 -10 9 1 for n in range(num):
    newnum = int(input())
    ans = max(ans,newnum - minnum)
    minnum = min(minnum,newnum) n range(num) range num newnum = int(input()) newnum int(input()) int input() input ans = max(ans,newnum - minnum) ans max(ans,newnum - minnum) max ans newnum - minnum newnum minnum minnum = min(minnum,newnum) minnum min(minnum,newnum) min minnum newnum print(ans) print ans ans = (-10 ** 9 - 1) -10 ** 9 - 1 ans newnum = int(input()) int(input()) newnum minnum = 10 ** 18 + 1 10 ** 18 + 1 minnum minnum = min(minnum,newnum) min(minnum,newnum) minnum num = int(input()) int(input()) num ans = max(ans,newnum - minnum) max(ans,newnum - minnum) ans
num = int(input())
minnum = 10 ** 18 + 1
ans = (-10 ** 9 - 1)
for n in range(num):
    newnum = int(input())
    ans = max(ans,newnum - minnum)
    minnum = min(minnum,newnum)
print(ans)