maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9

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

print(maxv) maxv = -2 * 10 ** 9 maxv -2 * 10 ** 9 -2 10 ** 9 10 9 minv = 2 * 10 ** 9 minv 2 * 10 ** 9 2 10 ** 9 10 9 n = int(input()) n int(input()) int input() input for i in range(n):
    x = int(input())
    maxv = max(x - minv, maxv)
    minv = min(x, minv) i range(n) range n x = int(input()) x int(input()) int input() input maxv = max(x - minv, maxv) maxv max(x - minv, maxv) max x - minv x minv maxv minv = min(x, minv) minv min(x, minv) min x minv print(maxv) print maxv minv = min(x, minv) min(x, minv) minv minv = 2 * 10 ** 9 2 * 10 ** 9 minv x = int(input()) int(input()) x maxv = -2 * 10 ** 9 -2 * 10 ** 9 maxv n = int(input()) int(input()) n maxv = max(x - minv, maxv) max(x - minv, maxv) maxv
maxv = -2 * 10 ** 9
minv = 2 * 10 ** 9

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

print(maxv)