num= n = int(input())

price = []
max_pro = -999999999

while(n>0):
    x = int(input())
    price.append(x)
    n -= 1
min = price[0]
for i in range(1,num):
    pro = price[i]-min

    if(max_pro < pro):
        max_pro = pro
    if(min > price[i]):
        min = price[i]
print ("{0}".format(max_pro)) num= n = int(input()) num int(input()) int input() input = n = int(input()) n int(input()) price = [] price [] max_pro = -999999999 max_pro -999999999 while(n>0):
    x = int(input())
    price.append(x)
    n -= 1 n>0 n 0 x = int(input()) x int(input()) int input() input price.append(x) price.append price append x n -= 1 n 1 min = price[0] min price[0] price 0 for i in range(1,num):
    pro = price[i]-min

    if(max_pro < pro):
        max_pro = pro
    if(min > price[i]):
        min = price[i] i range(1,num) range 1 num pro = price[i]-min pro price[i]-min price[i] price i min if(max_pro < pro):
        max_pro = pro
     max_pro < pro max_pro pro max_pro = pro max_pro pro if(min > price[i]):
        min = price[i] min > price[i] min price[i] price i min = price[i] min price[i] price i print ("{0}".format(max_pro)) print "{0}".format(max_pro) "{0}".format "{0}" format max_pro num= n = int(input()) int(input()) num max_pro = pro pro max_pro min = price[0] price[0] min price = [] [] price min = price[i] price[i] min max_pro = -999999999 -999999999 max_pro x = int(input()) int(input()) x n -= 1 1 n n = int(input()) int(input()) n pro = price[i]-min price[i]-min pro
num= n = int(input())

price = []
max_pro = -999999999

while(n>0):
    x = int(input())
    price.append(x)
    n -= 1
min = price[0]
for i in range(1,num):
    pro = price[i]-min

    if(max_pro < pro):
        max_pro = pro
    if(min > price[i]):
        min = price[i]
print ("{0}".format(max_pro))