# coding: utf-8
# Here your code !
import math
prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max=float("-inf")
min=li[0]
for j in range(1,d):
    if li[j]-min>max:
        max=li[j]-min
    if li[j]<min:
        min=li[j]

print(max) import math math prof = 0 prof 0 d = int(input()) d int(input()) int input() input int(input()) for i in range(d) for i in range(d) i range(d) range d for i in range(d) int(input()) int input() input li =[int(input()) for i in range(d)] li [int(input()) for i in range(d)] max=float("-inf") max float("-inf") float "-inf" min=li[0] min li[0] li 0 for j in range(1,d):
    if li[j]-min>max:
        max=li[j]-min
    if li[j]<min:
        min=li[j] j range(1,d) range 1 d if li[j]-min>max:
        max=li[j]-min
     li[j]-min>max li[j]-min li[j] li j min max max=li[j]-min max li[j]-min li[j] li j min if li[j]<min:
        min=li[j] li[j]<min li[j] li j min min=li[j] min li[j] li j print(max) print max prof = 0 0 prof max=li[j]-min li[j]-min max max=float("-inf") float("-inf") max li =[int(input()) for i in range(d)] [int(input()) for i in range(d)] li d = int(input()) int(input()) d min=li[j] li[j] min min=li[0] li[0] min
# coding: utf-8
# Here your code !
import math
prof = 0
d = int(input())
li =[int(input()) for i in range(d)]
max=float("-inf")
min=li[0]
for j in range(1,d):
    if li[j]-min>max:
        max=li[j]-min
    if li[j]<min:
        min=li[j]

print(max)