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