a=[]
n=int(input())
i=0
while(n>i):
    b=int(input())
    a.append(b)
    i+=1
score=-1000000000
mini = a[0]
for i in a[1:]:
    if(i-mini>score):
        score = i-mini
    if(mini>i):
        mini=i
    

print(score) a=[] a [] n=int(input()) n int(input()) int input() input i=0 i 0 while(n>i):
    b=int(input())
    a.append(b)
    i+=1 n>i n i b=int(input()) b int(input()) int input() input a.append(b) a.append a append b i+=1 i 1 score=-1000000000 score -1000000000 mini = a[0] mini a[0] a 0 for i in a[1:]:
    if(i-mini>score):
        score = i-mini
    if(mini>i):
        mini=i
     i a[1:] a 1: 1 if(i-mini>score):
        score = i-mini
     i-mini>score i-mini i mini score score = i-mini score i-mini i mini if(mini>i):
        mini=i
     mini>i mini i mini=i mini i print(score) print score a=[] [] a i=0 0 i score = i-mini i-mini score mini = a[0] a[0] mini i+=1 1 i score=-1000000000 -1000000000 score n=int(input()) int(input()) n b=int(input()) int(input()) b mini=i i mini
a=[]
n=int(input())
i=0
while(n>i):
    b=int(input())
    a.append(b)
    i+=1
score=-1000000000
mini = a[0]
for i in a[1:]:
    if(i-mini>score):
        score = i-mini
    if(mini>i):
        mini=i
    

print(score)