n=int(raw_input().strip())
lst=[]
minval=0x3f3f3f3f
ans=-0x3f3f3f3f
for i in xrange(n):
    val=int(raw_input().strip())
    if(i>=1):
        #print val,minval
        ans=max(ans,val-minval)
    minval = min(minval, val)
print ans
 n=int(raw_input().strip()) n int(raw_input().strip()) int raw_input().strip() ().strip () raw_input strip lst=[] lst [] minval=0x3f3f3f3f minval 0x3f3f3f3f ans=-0x3f3f3f3f ans -0x3f3f3f3f for i in xrange(n):
    val=int(raw_input().strip())
    if(i>=1):
        #print val,minval
        ans=max(ans,val-minval)
    minval = min(minval, val) i xrange(n) xrange n val=int(raw_input().strip()) val int(raw_input().strip()) int raw_input().strip() ().strip () raw_input strip if(i>=1):
        #print val,minval
        ans=max(ans,val-minval)
     i>=1 i 1 ans=max(ans,val-minval) ans max(ans,val-minval) max ans val-minval val minval minval = min(minval, val) minval min(minval, val) min minval val print lst=[] [] lst n=int(raw_input().strip()) int(raw_input().strip()) n minval=0x3f3f3f3f 0x3f3f3f3f minval ans=max(ans,val-minval) max(ans,val-minval) ans minval = min(minval, val) min(minval, val) minval ans=-0x3f3f3f3f -0x3f3f3f3f ans val=int(raw_input().strip()) int(raw_input().strip()) val
n=int(raw_input().strip())
lst=[]
minval=0x3f3f3f3f
ans=-0x3f3f3f3f
for i in xrange(n):
    val=int(raw_input().strip())
    if(i>=1):
        #print val,minval
        ans=max(ans,val-minval)
    minval = min(minval, val)
print ans

