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