config = {input: 'tmp', newline: '\r\n'}; // win
//config = {input: '/dev/stdin', newline: '\n'}; //linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .slice(1)
  .map(Number);

const NUM_MAX = 200000 + 1;
minRi = NUM_MAX;
max = -NUM_MAX;

for (i in line) {
  max = Math.max(max, line[i] - minRi);
  minRi = Math.min(minRi, line[i]);
}

console.log(max);