#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0,
      maxcount = 0, mincount = 0, x = 0, y = 0, z = 0;
  char rikka, toka[100000];
  string saya, homu, kyok, mami, mado[50];
  bool gg = true;
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> d[i];
    e[i] = d[i];
  }
  maxcount = max(d[0], d[1]);
  for (int j = 2; j < a; j++) {
    maxcount = max(maxcount, d[j]);
  }
  mincount = min(e[0], e[1]);
  for (int k = 2; k < a; k++) {
    mincount = min(mincount, e[k]);
  }
  cout << maxcount - mincount << endl;
  return 0;
}
