maxv = -1 * (10 ** 10) - 1
minv = 10 ** 10 + 1

n = int(input())

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

print(maxv) maxv = -1 * (10 ** 10) - 1 maxv -1 * (10 ** 10) - 1 -1 * (10 ** 10) -1 10 ** 10 10 10 1 minv = 10 ** 10 + 1 minv 10 ** 10 + 1 10 ** 10 10 10 1 n = int(input()) n int(input()) int input() input for i in range(n):
    tmp = int(input())
    
    maxv = max(maxv, tmp - minv)
    minv = min(tmp, minv) i range(n) range n tmp = int(input()) tmp int(input()) int input() input maxv = max(maxv, tmp - minv) maxv max(maxv, tmp - minv) max maxv tmp - minv tmp minv minv = min(tmp, minv) minv min(tmp, minv) min tmp minv print(maxv) print maxv maxv = -1 * (10 ** 10) - 1 -1 * (10 ** 10) - 1 maxv minv = 10 ** 10 + 1 10 ** 10 + 1 minv n = int(input()) int(input()) n tmp = int(input()) int(input()) tmp maxv = max(maxv, tmp - minv) max(maxv, tmp - minv) maxv minv = min(tmp, minv) min(tmp, minv) minv
maxv = -1 * (10 ** 10) - 1
minv = 10 ** 10 + 1

n = int(input())

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

print(maxv)