#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long A[n];
  int i, f = 0;
  long long temp = -1;
  for (i = 0; i < n; ++i) {
    cin >> A[i];
    if (temp > A[i]) {
      f = 1;
    }
    temp = A[i];
  }
  if (f == 0) {
    cout << 0 << endl;
  } else {
    sort(A, A + n);
    cout << (A[n - 1] - A[0]) << endl;
  }
}
