#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  uint32_t num;
  uint32_t mi = 0;
  uint32_t ma = UINT32_MAX;
  cin >> num;
  for (uint32_t i = 0; i < num; i++) {
    uint32_t val;
    cin >> val;
    mi = min(mi, val);
    ma = max(ma, val);
  }
  cout << ma - mi << endl;
}
