#include <bits/stdc++.h>
int main(void) {
  int i, n, a, b = 10000, c = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (b > a)
      b = a;
    else if (c <= a)
      c = a;
  }
  printf("%d\n", c - b);
  return 0;
}
