#include <bits/stdc++.h>
using namespace std;
int n, mmax, mmin, a;
int main() {
  cin >> n;
  cin >> mmin;
  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    if (a > mmax) {
      mmax = a;
    } else if (a < mmin) {
      mmin = a;
    }
  }
  cout << mmax - mmin;
}
