#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int i;
  cin >> n;
  int a[n];
  int max = 1, min = n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
    }
    if (a[i] < min) {
      min = a[i];
    }
  }
  cout << max - min << "\n";
  return 0;
}
