#ALDS_1_1_D Maximum Profit

N=int(input())
A=[]
for i in range(N):
    A.append(int(input())) 
MIN= A[0]
MAX= A[1]-A[0]
for i in range(1,N):
    MAX=max(MAX,A[i]-MIN)
    MIN=min(MIN,A[i])
print(MAX) N=int(input()) N int(input()) int input() input A=[] A [] 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 MAX= A[1]-A[0] MAX A[1]-A[0] A[1] A 1 A[0] A 0 for i in range(1,N):
    MAX=max(MAX,A[i]-MIN)
    MIN=min(MIN,A[i]) i range(1,N) range 1 N MAX=max(MAX,A[i]-MIN) MAX max(MAX,A[i]-MIN) max MAX A[i]-MIN A[i] A i MIN MIN=min(MIN,A[i]) MIN min(MIN,A[i]) min MIN A[i] A i print(MAX) print MAX A=[] [] A MIN=min(MIN,A[i]) min(MIN,A[i]) MIN MAX= A[1]-A[0] A[1]-A[0] MAX N=int(input()) int(input()) N MAX=max(MAX,A[i]-MIN) max(MAX,A[i]-MIN) MAX MIN= A[0] A[0] MIN
#ALDS_1_1_D Maximum Profit

N=int(input())
A=[]
for i in range(N):
    A.append(int(input())) 
MIN= A[0]
MAX= A[1]-A[0]
for i in range(1,N):
    MAX=max(MAX,A[i]-MIN)
    MIN=min(MIN,A[i])
print(MAX)
