#include <bits/stdc++.h>
int main(void) {
  int n, a;
  int min = -1, max = 1001;
  scanf("%d", &n);
  for (int loop = 0; loop < n; loop++) {
    scanf("%d", &a);
    if (min > a) {
      min = a;
    }
    if (max < a) {
      max = a;
    }
  }
  printf("%d\n", max - min);
  return 0;
}
