N=int(input())

a=int(input())
b=int(input())
min_number=min(a,b)
profit=b-a


for i in range(N-2):
	c=int(input())
	if profit<c-min_number:
		profit=c-min_number	
	if min_number>c:
		min_number=c


print(profit) N=int(input()) N int(input()) int input() input a=int(input()) a int(input()) int input() input b=int(input()) b int(input()) int input() input min_number=min(a,b) min_number min(a,b) min a b profit=b-a profit b-a b a for i in range(N-2):
	c=int(input())
	if profit<c-min_number:
		profit=c-min_number	
	if min_number>c:
		min_number=c i range(N-2) range N-2 N 2 c=int(input()) c int(input()) int input() input if profit<c-min_number:
		profit=c-min_number	
	 profit<c-min_number profit c-min_number c min_number profit=c-min_number profit c-min_number c min_number if min_number>c:
		min_number=c min_number>c min_number c min_number=c min_number c print(profit) print profit profit=c-min_number c-min_number profit b=int(input()) int(input()) b c=int(input()) int(input()) c N=int(input()) int(input()) N min_number=c c min_number profit=b-a b-a profit a=int(input()) int(input()) a min_number=min(a,b) min(a,b) min_number
N=int(input())

a=int(input())
b=int(input())
min_number=min(a,b)
profit=b-a


for i in range(N-2):
	c=int(input())
	if profit<c-min_number:
		profit=c-min_number	
	if min_number>c:
		min_number=c


print(profit)