#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, i, t = -1, t1 = 1e9;
int a[100001];
void inp() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    t = max(a[i], t);
    t1 = min(t1, a[i]);
  }
}
void process() { cout << ll(t - t1); }
int main() {
  inp();
  process();
  return 0;
}
