#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l = 0;
  cin >> n;
  int k = n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (a.at(i) <= k) k = a.at(i);
    if (a.at(i) >= l) l = a.at(i);
  }
  cout << l - k << endl;
}
