
n = gets.to_i
array = Array.new(n)

for i in 0..(n-1)
array[i] = gets.to_i
end

init = array[1]-array[0]

if n==2 then
puts init

else

for i in 0..(n-2)
for j in (i+1)..(n-1)

d = array[j]-array[i]
if d>init then
init = d
end

end
end

end
