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