n = gets.to_i
r = Array.new

n.times do
    r.push(gets.to_i)
end

# initialize max
max_r = cur_max = r[1] - r[0]
# calc
for i in 2..n-1 do
    tmp_r  = r[i] - r[i-1]
    if tmp_r > 0 then
        cur_max = cur_max > 0 ? max_r + tmp_r : tmp_r
        max_r = max_r < cur_max ? cur_max : max_r
    else
        max_r = max_r < tmp_r ? tmp_r : max_r
    end
end

puts max_r