gets
rate = $stdin.read.split.map(&:to_i)
maxv = rate[-1] - rate[0]
minv = rate[0]
1.upto(rate.length-1) do |i|
	d = rate[i].to_i - minv
	maxv = d if d>maxv
	minv = rate[i] if rate[i]<minv
end
puts maxv
