#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int mn = INT_MAX, mx = 0;
  for (int i = 1; i <= n; i++) {
    int ar;
    cin >> ar;
    mn = min(mn, ar);
    mx = max(mx, ar);
  }
  cout << mx - mn << endl;
  return 0;
}
