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

var max_value;
var min = 0;

for (var i = 1; i < numbers.length; i++) {
  if (i === 1) {
    min = numbers[i];
    continue;
  }
  max_value = typeof max_value === 'undefined' || numbers[i] - min > max_value ?  numbers[i] - min : max_value;
  min = numbers[i] < min ? numbers[i] : min;
}

console.log(max_value);
