#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, res = 0, cnt = 0;
  string s;
  cin >> n;
  long long int x;
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  };
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] << endl;
  return 0;
}
