process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !

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

var n = input[0]
var r = input.slice(1);

var min = Math.min.apply(null, r.slice(0, -1));
var max = Math.max.apply(null, r.slice(r.indexOf(min)))

console.log(max - min)