#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  int n;
  scanf("%d", &n);
  int a = 0, b = 0;
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    if (u < a || a == 0) a = u;
    if (u > b) b = u;
  }
  printf("%d\n", b - a);
  return 0;
}
