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

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