#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  vector<int> v;
  unsigned long long input;
  for (int i = 0; i < n; ++i) {
    cin >> input;
    v.push_back(input);
  }
  sort(v.begin(), v.end());
  cout << v.back() - v.front();
  return 0;
}
