n = int( raw_input( ) )

mi = int( raw_input( ) )
profit = 0 - 1000000000

for i in range( n-1 ):
	num = int( raw_input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num

print( profit ) n = int( raw_input( ) ) n int( raw_input( ) ) int raw_input( ) raw_input mi = int( raw_input( ) ) mi int( raw_input( ) ) int raw_input( ) raw_input profit = 0 - 1000000000 profit 0 - 1000000000 0 1000000000 for i in range( n-1 ):
	num = int( raw_input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num i range( n-1 ) range n-1 n 1 num = int( raw_input( ) ) num int( raw_input( ) ) int raw_input( ) raw_input diff = num - mi diff num - mi num mi if profit < diff:
		profit = diff

	 profit < diff profit diff profit = diff profit diff if num < mi:
		mi = num num < mi num mi mi = num mi num print( profit ) print profit n = int( raw_input( ) ) int( raw_input( ) ) n mi = int( raw_input( ) ) int( raw_input( ) ) mi profit = diff diff profit profit = 0 - 1000000000 0 - 1000000000 profit diff = num - mi num - mi diff num = int( raw_input( ) ) int( raw_input( ) ) num mi = num num mi
n = int( raw_input( ) )

mi = int( raw_input( ) )
profit = 0 - 1000000000

for i in range( n-1 ):
	num = int( raw_input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num

print( profit )