n=gets.chomp.to_i
ary=Array.new(n)
profit=0

maxp = -1*10**10

for m in 0..n-1
	ary[m]=gets.chomp.to_i
end

for j in 1..n-1
	if j>1
	for i in 0..j-1
		profit=ary[j]-ary[i]
		if maxp < profit
			maxp = profit
		end
	end
	end
end
puts maxp