# -*- coding: utf-8 -*-

if __name__ == '__main__':
	n = input()
	R = []

	for i in xrange(n):
		R.append(input())
	maxv = -20000000000
	minv = R[0]

	for i in xrange(1, n):
		maxv = max(maxv, R[i] - minv)
		minv = min(minv, R[i])

	print maxv if __name__ == '__main__':
	n = input()
	R = []

	for i in xrange(n):
		R.append(input())
	maxv = -20000000000
	minv = R[0]

	for i in xrange(1, n):
		maxv = max(maxv, R[i] - minv)
		minv = min(minv, R[i])

	print maxv __name__ == '__main__' __name__ '__main__' n = input() n input() input R = [] R [] for i in xrange(n):
		R.append(input())
	 i xrange(n) xrange n R.append(input()) R.append R append input() input maxv = -20000000000 maxv -20000000000 minv = R[0] minv R[0] R 0 for i in xrange(1, n):
		maxv = max(maxv, R[i] - minv)
		minv = min(minv, R[i])

	 i xrange(1, n) xrange 1 n maxv = max(maxv, R[i] - minv) maxv max(maxv, R[i] - minv) max maxv R[i] - minv R[i] R i minv minv = min(minv, R[i]) minv min(minv, R[i]) min minv R[i] R i print maxv = max(maxv, R[i] - minv) max(maxv, R[i] - minv) maxv n = input() input() n R = [] [] R minv = min(minv, R[i]) min(minv, R[i]) minv minv = R[0] R[0] minv maxv = -20000000000 -20000000000 maxv
# -*- coding: utf-8 -*-

if __name__ == '__main__':
	n = input()
	R = []

	for i in xrange(n):
		R.append(input())
	maxv = -20000000000
	minv = R[0]

	for i in xrange(1, n):
		maxv = max(maxv, R[i] - minv)
		minv = min(minv, R[i])

	print maxv