#include <bits/stdc++.h>
using namespace std;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(0);
  }
} fast;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
const long long inf = 1e9 + 7;
signed main(void) {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < (long long)(n); ++i) {
    cin >> v[i];
  }
  sort((v).begin(), (v).end());
  (v).erase(unique((v).begin(), (v).end()), (v).end());
  long long sum;
  for (long long i = 0; i < (long long)(v.size() - 1); ++i) {
    sum += v[i + 1] - v[i];
  }
  cout << sum << endl;
  return 0;
}
