const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);
const list = line.slice(1).map(x => parseInt(x));

const ans = list.reduce((acc, x, i, arr) => {
    const xs = arr.slice(i+1);
    if (xs.length > 0) {
        const max = xs.map(y => y - x).reduce((a, y) => a < y ? y : a);
        return acc < max ? max : acc;
    } else {
        return acc;
    }
}, -Infinity);

console.log(ans);

