#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int max = INT_MIN, min = INT_MAX;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x > max) max = x;
    if (x < min) min = x;
  }
  cout << max - min + 1 - N << endl;
}
