#coding:utf-8
#1_1_D
n = int(input())
prices = [int(input()) for x in range(n)]
maxv = -2 * 10 ** 9
minv = prices[0]
for i in range(1, n):
    maxv = max(maxv, prices[i] - minv)
    minv = min(minv, prices[i])

print(maxv) n = int(input()) n int(input()) int input() input int(input()) for x in range(n) for x in range(n) x range(n) range n for x in range(n) int(input()) int input() input prices = [int(input()) for x in range(n)] prices [int(input()) for x in range(n)] maxv = -2 * 10 ** 9 maxv -2 * 10 ** 9 -2 10 ** 9 10 9 minv = prices[0] minv prices[0] prices 0 for i in range(1, n):
    maxv = max(maxv, prices[i] - minv)
    minv = min(minv, prices[i]) i range(1, n) range 1 n maxv = max(maxv, prices[i] - minv) maxv max(maxv, prices[i] - minv) max maxv prices[i] - minv prices[i] prices i minv minv = min(minv, prices[i]) minv min(minv, prices[i]) min minv prices[i] prices i print(maxv) print maxv minv = prices[0] prices[0] minv maxv = max(maxv, prices[i] - minv) max(maxv, prices[i] - minv) maxv maxv = -2 * 10 ** 9 -2 * 10 ** 9 maxv prices = [int(input()) for x in range(n)] [int(input()) for x in range(n)] prices minv = min(minv, prices[i]) min(minv, prices[i]) minv n = int(input()) int(input()) n
#coding:utf-8
#1_1_D
n = int(input())
prices = [int(input()) for x in range(n)]
maxv = -2 * 10 ** 9
minv = prices[0]
for i in range(1, n):
    maxv = max(maxv, prices[i] - minv)
    minv = min(minv, prices[i])

print(maxv)