const inputs = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .trim()
  .split('\n')
  .map(Number);
inputs.shift();
let min = inputs[0];
let max = inputs[1] - inputs[0];
inputs.shift();
inputs.forEach(input => {
  max = Math.max(max, input - min);
  min = Math.min(min, input);
});
console.log(max);

