import sys
n = int(input())
r = [int(input()) for x in range(n)]
max_val = sys.maxsize * -1
min_val = r[0]
for i in range(1,n):
  max_val = max(max_val, r[i] - min_val)
  min_val = min(min_val, r[i])
print(max_val)
 import sys sys n = int(input()) n int(input()) int input() input int(input()) for x in range(n) for x in range(n) x range(n) range n for x in range(n) int(input()) int input() input r = [int(input()) for x in range(n)] r [int(input()) for x in range(n)] max_val = sys.maxsize * -1 max_val sys.maxsize * -1 sys.maxsize sys maxsize -1 min_val = r[0] min_val r[0] r 0 for i in range(1,n):
  max_val = max(max_val, r[i] - min_val)
  min_val = min(min_val, r[i]) i range(1,n) range 1 n max_val = max(max_val, r[i] - min_val) max_val max(max_val, r[i] - min_val) max max_val r[i] - min_val r[i] r i min_val min_val = min(min_val, r[i]) min_val min(min_val, r[i]) min min_val r[i] r i print(max_val) print max_val max_val = sys.maxsize * -1 sys.maxsize * -1 max_val max_val = max(max_val, r[i] - min_val) max(max_val, r[i] - min_val) max_val n = int(input()) int(input()) n min_val = r[0] r[0] min_val min_val = min(min_val, r[i]) min(min_val, r[i]) min_val r = [int(input()) for x in range(n)] [int(input()) for x in range(n)] r
import sys
n = int(input())
r = [int(input()) for x in range(n)]
max_val = sys.maxsize * -1
min_val = r[0]
for i in range(1,n):
  max_val = max(max_val, r[i] - min_val)
  min_val = min(min_val, r[i])
print(max_val)

