#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const* argv[]) {
  int n, i, ans = 0, a, min = 0, max = 0;
  vector<int> buckets(1000 + 1, 0);
  cin >> n;
  for (i = 0; i <= n; i++) {
    cin >> a;
    if (buckets[a] == 0) buckets[a] += 1;
  }
  for (i = 1; i <= 1000; i++) {
    if (buckets[i] != 0) {
      min = i;
      break;
    }
  }
  for (i = 1000; i >= 1; i--) {
    if (buckets[i] != 0) {
      max = i;
      break;
    }
  }
  ans = max - min;
  cout << ans << endl;
  return 0;
}
