s = int(input())
maxv = -100000000000000000
minv = 10000000000000000

for i in range(s):
    x = int(input())
    maxv = max(maxv,x-minv)
    minv = min(minv,x)



if x >= 0:
    print(maxv)
else:
    print("-1")
 s = int(input()) s int(input()) int input() input maxv = -100000000000000000 maxv -100000000000000000 minv = 10000000000000000 minv 10000000000000000 for i in range(s):
    x = int(input())
    maxv = max(maxv,x-minv)
    minv = min(minv,x) i range(s) range s x = int(input()) x int(input()) int input() input maxv = max(maxv,x-minv) maxv max(maxv,x-minv) max maxv x-minv x minv minv = min(minv,x) minv min(minv,x) min minv x if x >= 0:
    print(maxv)
else:
    print("-1") x >= 0 x 0 print(maxv) print maxv print("-1") print "-1" minv = min(minv,x) min(minv,x) minv maxv = -100000000000000000 -100000000000000000 maxv minv = 10000000000000000 10000000000000000 minv s = int(input()) int(input()) s x = int(input()) int(input()) x maxv = max(maxv,x-minv) max(maxv,x-minv) maxv
s = int(input())
maxv = -100000000000000000
minv = 10000000000000000

for i in range(s):
    x = int(input())
    maxv = max(maxv,x-minv)
    minv = min(minv,x)



if x >= 0:
    print(maxv)
else:
    print("-1")

