const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.split("\n").map(Number);

let min = lines[1];

let n = lines[2]-lines[1];

for(var i =3;i<lines[0]+1;i++){
    if(lines[i-1]<min){
        min = lines[i-1]
    }

    if(lines[i]-min>n){
        n = lines[i]-min
    }

}

console.log(n)
