#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    a.push_back(k);
  }
  sort(a.begin(), a.end());
  if (a[0] == a[n - 1])
    cout << "0\n";
  else
    cout << abs(a[n - 1] - a[0]) << endl;
}
