#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<long long> arr;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  sort(arr.begin(), arr.end());
  cout << arr[n - 1] - arr[0] << endl;
  return 0;
}
