#include <bits/stdc++.h>
int main() {
  int n;
  int arr[200100] = {0};
  int i;
  int min = 1000000009;
  int max = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] < min) {
      min = arr[i];
    }
    if (arr[i] > max) {
      max = arr[i];
    }
  }
  printf("%d", max - min);
}
