#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &it : v) cin >> it;
  sort(v.begin(), v.end());
  cout << v[n - 1] - v[0] + 1 - n;
  return 0;
}
