function Main(input) {
  var inputs = input.split("\n");
  var n = parseInt(inputs[0], 10);
  var a = inputs[1].split(" ").map(e => parseInt(e, 10));
  var max = 0;
  var min = 1000000001;
  for(var i = 0; i < n; i++) {
    max = a[i] > max ? a[i]:max;
    min = a[i] < min ? a[i]:min;
  }
  console.log(max - min);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));