if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv) if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input R = [int(input()) for i in range(n)] R [int(input()) for i in range(n)] minv = R[0] minv R[0] R 0 maxv = R[1] - R[0] maxv R[1] - R[0] R[1] R 1 R[0] R 0 for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	 j range(1, n) range 1 n if (maxv < R[j] - minv):
			maxv = R[j] - minv
		 maxv < R[j] - minv maxv R[j] - minv R[j] R j minv maxv = R[j] - minv maxv R[j] - minv R[j] R j minv if (R[j] < minv):
			minv = R[j]
	 R[j] < minv R[j] R j minv minv = R[j] minv R[j] R j print(maxv) print maxv maxv = R[j] - minv R[j] - minv maxv minv = R[0] R[0] minv n = int(input()) int(input()) n minv = R[j] R[j] minv maxv = R[1] - R[0] R[1] - R[0] maxv R = [int(input()) for i in range(n)] [int(input()) for i in range(n)] R
if __name__ == '__main__':
	n = int(input())
	R = [int(input()) for i in range(n)]

	minv = R[0]
	maxv = R[1] - R[0]
	for j in range(1, n):
		if (maxv < R[j] - minv):
			maxv = R[j] - minv
		if (R[j] < minv):
			minv = R[j]
	print(maxv)