#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, cnt = 0;
  cin >> a;
  int arr[a];
  for (int i = 1; i <= a; i++) cin >> arr[i];
  sort(arr, arr + a);
  for (int i = 0; i < a - 1; i++) cnt += abs(arr[i] - arr[i + 1]);
  cout << cnt << endl;
  return 0;
}
