const input = require("fs").readFileSync("/dev/stdin", "utf8")
const array = (input.trim()).split('\n').map(Number)
array.shift()

var maxV = array[1] - array[0]
var minV = array[0]

array.shift()

array.forEach(curV => {
    maxV = Math.max(maxV, curV - minV)
    minV = Math.min(minV, curV)
})

console.log(maxV)

