N=int(input())
R=[int(input()) for i in range(N)]
S=[0 for i in range(N)]
S[0]=R[0]
for i in range(1,N):
    S[i]=min(S[i-1],R[i])
T=[R[i+1]-S[i] for i in range(N-1)]
print(max(T))
 N=int(input()) N int(input()) int input() input int(input()) for i in range(N) for i in range(N) i range(N) range N for i in range(N) int(input()) int input() input R=[int(input()) for i in range(N)] R [int(input()) for i in range(N)] 0 for i in range(N) for i in range(N) i range(N) range N for i in range(N) 0 S=[0 for i in range(N)] S [0 for i in range(N)] S[0]=R[0] S[0] S 0 R[0] R 0 for i in range(1,N):
    S[i]=min(S[i-1],R[i]) i range(1,N) range 1 N S[i]=min(S[i-1],R[i]) S[i] S i min(S[i-1],R[i]) min S[i-1] S i-1 i 1 R[i] R i R[i+1]-S[i] for i in range(N-1) for i in range(N-1) i range(N-1) range N-1 N 1 for i in range(N-1) R[i+1]-S[i] R[i+1] R i+1 i 1 S[i] S i T=[R[i+1]-S[i] for i in range(N-1)] T [R[i+1]-S[i] for i in range(N-1)] print(max(T)) print max(T) max T N=int(input()) int(input()) N S=[0 for i in range(N)] [0 for i in range(N)] S R=[int(input()) for i in range(N)] [int(input()) for i in range(N)] R T=[R[i+1]-S[i] for i in range(N-1)] [R[i+1]-S[i] for i in range(N-1)] T
N=int(input())
R=[int(input()) for i in range(N)]
S=[0 for i in range(N)]
S[0]=R[0]
for i in range(1,N):
    S[i]=min(S[i-1],R[i])
T=[R[i+1]-S[i] for i in range(N-1)]
print(max(T))

