#include <bits/stdc++.h>
int gcd(int a, int b) {
  if (a < b) {
    int now = a;
    a = b;
    b = a;
  }
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
int main(void) {
  int n;
  scanf("%d", &n);
  int g = 0;
  int f = 1000;
  int i;
  for (i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a < f) {
      f = a;
    }
    if (a < g) {
      g = a;
    }
  }
  printf("%d\n", g - f);
  return 0;
}
