#include <bits/stdc++.h>
int main() {
  long long int n, i, min = 100000000, max = -1;
  scanf("%lld", &n);
  long long int a[n];
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] > max) max = a[i];
    if (a[i] < min) min = a[i];
  }
  printf("%lld\n", max - min);
  return 0;
}
