#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x;
  cin >> n;
  int max = INT_MIN, min = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x > max) max = x;
    if (x < min) min = x;
  }
  cout << (max - min + 1) - n;
  return 0;
}
