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