#ALDS1_1_D Maximum Profit
n=int(input())
A=[]
max_dif=-1*10**9
for i in range(n):
    A.append(int(input()))
min=A[0]
for i in range(n-1):
    if(A[i+1]-min>max_dif):
        max_dif=A[i+1]-min
    if(min>A[i+1]):
        min=A[i+1]
print(max_dif) n=int(input()) n int(input()) int input() input A=[] A [] max_dif=-1*10**9 max_dif -1*10**9 -1 10**9 10 9 for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input min=A[0] min A[0] A 0 for i in range(n-1):
    if(A[i+1]-min>max_dif):
        max_dif=A[i+1]-min
    if(min>A[i+1]):
        min=A[i+1] i range(n-1) range n-1 n 1 if(A[i+1]-min>max_dif):
        max_dif=A[i+1]-min
     A[i+1]-min>max_dif A[i+1]-min A[i+1] A i+1 i 1 min max_dif max_dif=A[i+1]-min max_dif A[i+1]-min A[i+1] A i+1 i 1 min if(min>A[i+1]):
        min=A[i+1] min>A[i+1] min A[i+1] A i+1 i 1 min=A[i+1] min A[i+1] A i+1 i 1 print(max_dif) print max_dif min=A[i+1] A[i+1] min max_dif=A[i+1]-min A[i+1]-min max_dif min=A[0] A[0] min n=int(input()) int(input()) n A=[] [] A max_dif=-1*10**9 -1*10**9 max_dif
#ALDS1_1_D Maximum Profit
n=int(input())
A=[]
max_dif=-1*10**9
for i in range(n):
    A.append(int(input()))
min=A[0]
for i in range(n-1):
    if(A[i+1]-min>max_dif):
        max_dif=A[i+1]-min
    if(min>A[i+1]):
        min=A[i+1]
print(max_dif)