N = int(input())
A = input().split()
A = [int(x) for x in A]

diff, diffm = 0,0

for i in range(len(A)-1):
  for j in range(len(A)-i-1):
    diff = A[j+i+1] - A[i]
    
    if diff > diffm: diffm = diff
      
print(diffm)