n = int( raw_input( ) )

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

	if num < mi:
		mi = num
	i += 1

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 n -= 1 n 1 i = 0 i 0 while i < n:
	num = int( raw_input( ) )
	
	diff = num - mi
	if profit < diff:
		profit = diff

	if num < mi:
		mi = num
	i += 1 i < n i n 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 i += 1 i 1 print( profit ) print profit n = int( raw_input( ) ) int( raw_input( ) ) n i += 1 1 i profit = 0 - 1000000000 0 - 1000000000 profit n -= 1 1 n diff = num - mi num - mi diff profit = diff diff profit mi = int( raw_input( ) ) int( raw_input( ) ) mi mi = num num mi i = 0 0 i num = int( raw_input( ) ) int( raw_input( ) ) num
n = int( raw_input( ) )

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

	if num < mi:
		mi = num
	i += 1

print( profit )