N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
max_profit = a[1] - a[0]
min_val = min(a[1],a[0])
for i in range(2,N):
	if a[i] < min_val:
		min_val = a[i]
	elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val
print(str(max_profit)) N = int(input()) N int(input()) int input() input a = [] a [] for i in range(N):
    a.append(int(input())) i range(N) range N a.append(int(input())) a.append a append int(input()) int input() input max_profit = a[1] - a[0] max_profit a[1] - a[0] a[1] a 1 a[0] a 0 min_val = min(a[1],a[0]) min_val min(a[1],a[0]) min a[1] a 1 a[0] a 0 for i in range(2,N):
	if a[i] < min_val:
		min_val = a[i]
	elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val i range(2,N) range 2 N if a[i] < min_val:
		min_val = a[i]
	elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val a[i] < min_val a[i] a i min_val min_val = a[i] min_val a[i] a i elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val a[i] - min_val > max_profit a[i] - min_val a[i] a i min_val max_profit max_profit = a[i] - min_val max_profit a[i] - min_val a[i] a i min_val print(str(max_profit)) print str(max_profit) str max_profit max_profit = a[1] - a[0] a[1] - a[0] max_profit max_profit = a[i] - min_val a[i] - min_val max_profit a = [] [] a min_val = min(a[1],a[0]) min(a[1],a[0]) min_val N = int(input()) int(input()) N min_val = a[i] a[i] min_val
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
max_profit = a[1] - a[0]
min_val = min(a[1],a[0])
for i in range(2,N):
	if a[i] < min_val:
		min_val = a[i]
	elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val
print(str(max_profit))