function main()
    data = readlines()
    N = parse(Int, data[1])
    A = parse.(Int, split(data[2]))
    B = zeros(Int, N-1)
    for n in 2:N
        B[n-1] = max(0, A[n]-A[n-1])
    end
    println(maximum(B))
end
main()