#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int maximum = 1e9, minimum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    maximum = max(maximum, x);
    minimum = min(minimum, x);
  }
  cout << maximum - minimum;
}
