process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

function main(inputs) {
  var N = parseInt(inputs[0]);
  var vs = inputs[1].split(" ").map(function(a){return parseInt(a);});
  var max = 0;
  var min = 100000;
  for(var i in vs){
    max = Math.max(max, vs[i]);
    min = Math.min(min, vs[i]);
  }
  console.log(max - min);
}
