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