#include <bits/stdc++.h>
int main(void) {
  char a[400000], w[10];
  int n, num[101], i, j, k, max, min;
  scanf("%d", &n);
  rewind(stdin);
  gets(a);
  j = 0;
  k = 0;
  for (i = 0; a[i] != '\0'; i++) {
    if (a[i] == ' ') {
      w[j] = '\0';
      num[k++] = atoi(w);
      j = 0;
    }
    w[j++] = a[i];
  }
  w[j] = '\0';
  num[k++] = atoi(w);
  max = num[0];
  min = num[0];
  for (i = 1; i < n; i++) {
    if (max < num[i]) max = num[i];
    if (min > num[i]) min = num[i];
  }
  printf("%d", max - min);
  return 0;
}
