l = 2*10**9
p = -2*10**9
n = int(input())
for _ in range(n):
	x = int(input())
	p = max(x-l,p)
	l = min(x,l)
print(p) l = 2*10**9 l 2*10**9 2 10**9 10 9 p = -2*10**9 p -2*10**9 -2 10**9 10 9 n = int(input()) n int(input()) int input() input for _ in range(n):
	x = int(input())
	p = max(x-l,p)
	l = min(x,l) _ range(n) range n x = int(input()) x int(input()) int input() input p = max(x-l,p) p max(x-l,p) max x-l x l p l = min(x,l) l min(x,l) min x l print(p) print p n = int(input()) int(input()) n l = 2*10**9 2*10**9 l x = int(input()) int(input()) x p = max(x-l,p) max(x-l,p) p l = min(x,l) min(x,l) l p = -2*10**9 -2*10**9 p
l = 2*10**9
p = -2*10**9
n = int(input())
for _ in range(n):
	x = int(input())
	p = max(x-l,p)
	l = min(x,l)
print(p)