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