#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, sum = 0;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long max = a[0];
  long long min = a[0];
  for (long long i = 1; i < n; i++) {
    if (max < a[i]) max = a[i];
  }
  for (long long i = 1; i < n; i++) {
    if (min > a[i]) min = a[i];
  }
  cout << (max - min);
}
