import sys
d = -float('inf')
n = int(input())
l = int(input())
for s in sys.stdin:
	r = int(s)
	d = max(d, r-l)
	l = min(l, r)
print(d) import sys sys d = -float('inf') d -float('inf') float('inf') float 'inf' n = int(input()) n int(input()) int input() input l = int(input()) l int(input()) int input() input for s in sys.stdin:
	r = int(s)
	d = max(d, r-l)
	l = min(l, r) s sys.stdin sys stdin r = int(s) r int(s) int s d = max(d, r-l) d max(d, r-l) max d r-l r l l = min(l, r) l min(l, r) min l r print(d) print d n = int(input()) int(input()) n d = max(d, r-l) max(d, r-l) d d = -float('inf') -float('inf') d l = int(input()) int(input()) l r = int(s) int(s) r l = min(l, r) min(l, r) l
import sys
d = -float('inf')
n = int(input())
l = int(input())
for s in sys.stdin:
	r = int(s)
	d = max(d, r-l)
	l = min(l, r)
print(d)
