R = Array.new(200000)

n = gets.to_i

for i in 0..n-1 do
      R[i] = gets.to_i
end

for i in 1..n-1 do

   if i ==1
	  maxv = R[i] - R[i-1]
	  minv = R[i-1]
   end

   if maxv < R[i] -minv
	  maxv = R[i] - minv
   end

   if  R[i] < minv
	  minv = R[i]
   end

   puts "i=" + i.to_s
   puts "maxv =" + maxv.to_s
   puts "minv =" + minv.to_s

end

puts maxv

