#include <bits/stdc++.h>
int main(void) {
  int n, a[101], count = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] > a[j + 1]) {
        int temp = a[j];
        a[j] = a[j + 1];
        a[j + 1] = temp;
      }
    }
  }
  for (int i = 0; i < n - 1; i++) count += a[i + 1] - a[i];
  printf("%d", count);
  return 0;
}
