#include <bits/stdc++.h>
using namespace std;
int pos[1256];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> pos[i];
  }
  sort(pos, pos + n);
  int m = (pos[n - 1] == pos[0]) ? 0 : pos[n - 1] - pos[0] + 1;
  cout << m;
  return 0;
}
