def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

m = -1000000001
ti = 1000000001
for i in range(len(numbers) - 1):
    if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i]

print (m) def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now calcMax now = numbers[i] now numbers[i] numbers i future_max = max(numbers[i+1:]) future_max max(numbers[i+1:]) max numbers[i+1:] numbers i+1: i+1 i 1 t = numbers[i+1:] t numbers[i+1:] numbers i+1: i+1 i 1 return future_max - now future_max - now future_max now i i n = int(input()) n int(input()) int input() input numbers = [] numbers [] for i in range(n):
  numbers.append(int(input())) i range(n) range n numbers.append(int(input())) numbers.append numbers append int(input()) int input() input m = -1000000001 m -1000000001 ti = 1000000001 ti 1000000001 for i in range(len(numbers) - 1):
    if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i] i range(len(numbers) - 1) range len(numbers) - 1 len(numbers) len numbers 1 if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i] numbers[i] < ti numbers[i] numbers i ti if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i] i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1]) i == 0 or i == len(numbers) - 1 i == 0 i 0 i == len(numbers) - 1 i len(numbers) - 1 len(numbers) len numbers 1 numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1] numbers[i-1] >= numbers[i] numbers[i-1] numbers i-1 i 1 numbers[i] numbers i numbers[i] <= numbers[i+1] numbers[i] numbers i numbers[i+1] numbers i+1 i 1 temp = calcMax(i) temp calcMax(i) calcMax i if temp > m:
            m = temp
            ti = numbers[i] temp > m temp m m = temp m temp ti = numbers[i] ti numbers[i] numbers i print (m) print m ti = 1000000001 1000000001 ti m = temp temp m ti = numbers[i] numbers[i] ti n = int(input()) int(input()) n temp = calcMax(i) calcMax(i) temp numbers = [] [] numbers def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now calcMax m = -1000000001 -1000000001 m
def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

m = -1000000001
ti = 1000000001
for i in range(len(numbers) - 1):
    if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i]

print (m)
