#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, x, ma, mi = 1e9 + 10;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    ma = max(ma, x);
    mi = min(mi, x);
  }
  cout << ma - mi << endl;
  return 0;
}
