#include <bits/stdc++.h>
using namespace std;
template <class TT>
void mySwap(TT& a, TT& b) {
  TT c(a);
  a = b;
  b = c;
}
template <typename T>
void select_sort(T* arr, int arr_length) {
  T min;
  T swap;
  int index;
  for (int i = 0; i < arr_length; i++) {
    min = arr[i];
    index = i;
    for (int j = i; j < arr_length; j++) {
      if (min > arr[j]) index = j;
    }
    if (index != i) mySwap(arr[i], arr[index]);
  }
}
int main() {
  int N;
  cin >> N;
  int* a;
  a = (int*)malloc(sizeof(int) * N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  select_sort(a, N);
  int ans = 0;
  for (int i = 1; i < N; i++) {
    ans += a[i] - a[i - 1];
  }
  cout << ans;
  return 0;
}
