N = gets.to_i
list = Array.new
N.times do |i|
list[i] = gets.to_i
end

s = Array.new

(N-1).times do |i|
	s[i] = (list[i+1]-list[i]).to_i
end

sum=0
max=-1000000000
(N-1).times do |i|
sum += s[i]
if(sum>max)
 max=sum 
end
if sum<0
sum=0
end

end

puts max