#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[1005];
  int minn = 1e9, maxn = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    minn = min(minn, a[i]);
    maxn = max(maxn, a[i]);
  }
  cout << maxn - minn - n + 1;
}
