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