// Here your code !

var input = require('fs').readFileSync('/dev/stdin', 'utf8')
input = input.trim().split('\n').map(Number);

var n = input[0]
var rList = input.slice(1);
var result = 0

for (let index = 0; index < rList.length; index ++) {
    if (index + 1 === n) {
        break;
    }

    var calc = rList[index] - rList[index + 1]
    if (result < calc) {
        result = calc;
    }
}
console.log(result)