#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  int mx = -1, mn = INT_MAX;
  for (int i = 0; i < n; i++) {
    int inp;
    cin >> inp;
    mn = min(mn, inp), mx = max(mx, inp);
  }
  cout << mx - mn + 1 - n << endl;
}
