#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> place(n);
  for (int i = 0; i < n; i++) {
    cin >> place.at(i);
  }
  sort(place.begin(), place.end());
  cout << place.at(n - 1) - place.at(1) << endl;
}
