#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[1000];
  cin >> a[0];
  if (N == 1) {
    cout << a[0] << endl;
  } else if (N == 2) {
    cin >> a[1];
    cout << abs(a[1] - a[0]) << endl;
  } else {
    int temp[2];
    cin >> a[1];
    if (a[0] == a[1]) {
      temp[1] = a[0];
    } else if (a[0] > a[1]) {
      temp[1] = a[0];
      temp[0] = a[1];
    } else {
      temp[1] = a[1];
      temp[0] = a[0];
    }
    for (int i = 3; i <= N; i++) {
      cin >> a[i];
      if (temp[0] > a[i]) {
        temp[0] = a[i];
      }
      if (temp[1] < a[i]) {
        temp[1] = a[i];
      }
    }
    cout << temp[1] - temp[0] << endl;
  }
}
