n = int(input())
DifMax = -9999999999999

R = [int(input())]
RMin = R[0]
for i in range(1, n):
  if RMin > R[i-1]:
      RMin = R[i-1]
  R.append(int(input()))
  if DifMax < R[i] - RMin:
    DifMax = R[i] - RMin

print(DifMax) n = int(input()) n int(input()) int input() input DifMax = -9999999999999 DifMax -9999999999999 R = [int(input())] R [int(input())] int(input()) int input() input RMin = R[0] RMin R[0] R 0 for i in range(1, n):
  if RMin > R[i-1]:
      RMin = R[i-1]
  R.append(int(input()))
  if DifMax < R[i] - RMin:
    DifMax = R[i] - RMin i range(1, n) range 1 n if RMin > R[i-1]:
      RMin = R[i-1]
   RMin > R[i-1] RMin R[i-1] R i-1 i 1 RMin = R[i-1] RMin R[i-1] R i-1 i 1 R.append(int(input())) R.append R append int(input()) int input() input if DifMax < R[i] - RMin:
    DifMax = R[i] - RMin DifMax < R[i] - RMin DifMax R[i] - RMin R[i] R i RMin DifMax = R[i] - RMin DifMax R[i] - RMin R[i] R i RMin print(DifMax) print DifMax RMin = R[0] R[0] RMin n = int(input()) int(input()) n DifMax = -9999999999999 -9999999999999 DifMax R = [int(input())] [int(input())] R RMin = R[i-1] R[i-1] RMin DifMax = R[i] - RMin R[i] - RMin DifMax
n = int(input())
DifMax = -9999999999999

R = [int(input())]
RMin = R[0]
for i in range(1, n):
  if RMin > R[i-1]:
      RMin = R[i-1]
  R.append(int(input()))
  if DifMax < R[i] - RMin:
    DifMax = R[i] - RMin

print(DifMax)