var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
lines.shift();
 
var result = Number.NEGATIVE_INFINITY;
for (var i = 0; i < lines.length; i++) {
    for (var j = i + 1; j <= lines.length; j++) {
        if (((lines[j] - lines[i]) || 0) >= result)
            result = ((lines[j] - lines[i]) || 0);
    }
}
 
console.log(result);