#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 10e5;
int n, a[MAXN], b[MAXN], ans = 0;
bool mycmp(int a, int b) { return a > b; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a + 1, a + 1 + n);
  int x = a[1];
  sort(b + 1, b + 1 + n, mycmp);
  int y = b[1];
  cout << y - x;
  return 0;
}
