#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int mx = 0, mi = 1000000000;
  int ar[n];
  for (size_t i = 0; i < n; i++) {
    int k;
    cin >> k;
    mx = max(mx, k);
    mi = min(k, mi);
  }
  cout << mx - mi << endl;
  return 0;
}
