n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro) n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input ps = [int(input()) for _ in range(n)] ps [int(input()) for _ in range(n)] maxpro = -999999999 maxpro -999999999 minp = 1000000000 minp 1000000000 for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p i p enumerate(ps[:-1]) enumerate ps[:-1] ps :-1 -1 if p >= minp: continue
   p >= minp p minp pro = max(ps[i + 1:]) - p pro max(ps[i + 1:]) - p max(ps[i + 1:]) max ps[i + 1:] ps i + 1: i + 1 i 1 p maxpro = max(pro, maxpro) maxpro max(pro, maxpro) max pro maxpro minp = p minp p print(maxpro) print maxpro maxpro = max(pro, maxpro) max(pro, maxpro) maxpro minp = 1000000000 1000000000 minp minp = p p minp n = int(input()) int(input()) n maxpro = -999999999 -999999999 maxpro pro = max(ps[i + 1:]) - p max(ps[i + 1:]) - p pro ps = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] ps
n = int(input())
ps = [int(input()) for _ in range(n)]
maxpro = -999999999
minp = 1000000000
for i, p in enumerate(ps[:-1]):
  if p >= minp: continue
  pro = max(ps[i + 1:]) - p
  maxpro = max(pro, maxpro)
  minp = p
print(maxpro)