#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum = 0;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  for (int i = n - 2; i >= 0; i--) {
    sum += v[i + 1] - v[i];
  }
  cout << sum << endl;
}
