data_num = int(input())
cnt = 0
deff_price = -999999999
min_price = 0
tmp_price = 0

for i in range(data_num):
    price = int(input())
 
    if i ==0:
        min_price = price
    elif price - min_price > deff_price:
        deff_price = price - min_price
    
    if price < min_price:
        min_price = price

print(str(deff_price)) data_num = int(input()) data_num int(input()) int input() input cnt = 0 cnt 0 deff_price = -999999999 deff_price -999999999 min_price = 0 min_price 0 tmp_price = 0 tmp_price 0 for i in range(data_num):
    price = int(input())
 
    if i ==0:
        min_price = price
    elif price - min_price > deff_price:
        deff_price = price - min_price
    
    if price < min_price:
        min_price = price i range(data_num) range data_num price = int(input()) price int(input()) int input() input if i ==0:
        min_price = price
    elif price - min_price > deff_price:
        deff_price = price - min_price
    
     i ==0 i 0 min_price = price min_price price elif price - min_price > deff_price:
        deff_price = price - min_price
    
     price - min_price > deff_price price - min_price price min_price deff_price deff_price = price - min_price deff_price price - min_price price min_price if price < min_price:
        min_price = price price < min_price price min_price min_price = price min_price price print(str(deff_price)) print str(deff_price) str deff_price min_price = price price min_price tmp_price = 0 0 tmp_price price = int(input()) int(input()) price cnt = 0 0 cnt min_price = 0 0 min_price deff_price = -999999999 -999999999 deff_price min_price = price price min_price deff_price = price - min_price price - min_price deff_price data_num = int(input()) int(input()) data_num
data_num = int(input())
cnt = 0
deff_price = -999999999
min_price = 0
tmp_price = 0

for i in range(data_num):
    price = int(input())
 
    if i ==0:
        min_price = price
    elif price - min_price > deff_price:
        deff_price = price - min_price
    
    if price < min_price:
        min_price = price

print(str(deff_price))