#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, ma = -1e9, mi = 1e9;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j;
    ma = max(j, ma);
    mi = min(j, mi);
  }
  cout << (ma - mi + 1 - n) << endl;
  return 0;
}
