#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, tmp, mn = 1000000000 + 9, mx = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    mn = min(mn, tmp);
    mx = max(mx, tmp);
  }
  cout << mx - mn + 1 - n;
  return 0;
}
