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