n = int(input())

r0 = int(input())
r1 = int(input())
max = r1-r0
min = min(r0,r1)
for i in range(n-2):
    r = int(input())
    if max < r-min:
        max = r-min
    if min > r:
        min = r
print(max) n = int(input()) n int(input()) int input() input r0 = int(input()) r0 int(input()) int input() input r1 = int(input()) r1 int(input()) int input() input max = r1-r0 max r1-r0 r1 r0 min = min(r0,r1) min min(r0,r1) min r0 r1 for i in range(n-2):
    r = int(input())
    if max < r-min:
        max = r-min
    if min > r:
        min = r i range(n-2) range n-2 n 2 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 min > r:
        min = r min > r min r min = r min r print(max) print max max = r-min r-min max r = int(input()) int(input()) r n = int(input()) int(input()) n r0 = int(input()) int(input()) r0 max = r1-r0 r1-r0 max r1 = int(input()) int(input()) r1 min = min(r0,r1) min(r0,r1) min min = r r min
n = int(input())

r0 = int(input())
r1 = int(input())
max = r1-r0
min = min(r0,r1)
for i in range(n-2):
    r = int(input())
    if max < r-min:
        max = r-min
    if min > r:
        min = r
print(max)