#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, soma = 0;
  cin >> n;
  int houses[n];
  for (int i = 0; i < n; i++) {
    cin >> houses[i];
  }
  sort(houses, houses + n);
  for (int i = n - 1; i > 0; i--) {
    soma += houses[i] - houses[i - 1];
  }
  cout << soma;
}
