max = -10 ** 9
n = int(input())
min = int(input())
for _ in range(n - 1):
    r = int(input())
    if max < (r - min):
        max = r - min
    if r < min:
        min = r
print(max) max = -10 ** 9 max -10 ** 9 -10 9 n = int(input()) n int(input()) int input() input min = int(input()) min int(input()) int input() input for _ in range(n - 1):
    r = int(input())
    if max < (r - min):
        max = r - min
    if r < min:
        min = r _ range(n - 1) range n - 1 n 1 r = int(input()) r int(input()) int input() input if max < (r - min):
        max = r - min
     max < (r - min) max r - min r min max = r - min max r - min r min if r < min:
        min = r r < min r min min = r min r print(max) print max min = int(input()) int(input()) min n = int(input()) int(input()) n max = r - min r - min max max = -10 ** 9 -10 ** 9 max r = int(input()) int(input()) r min = r r min
max = -10 ** 9
n = int(input())
min = int(input())
for _ in range(n - 1):
    r = int(input())
    if max < (r - min):
        max = r - min
    if r < min:
        min = r
print(max)