#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max = -1, min = 1e9 + 2;
  cin >> n;
  int u = n;
  while (n--) {
    int a;
    scanf("%d", &a);
    max = (max > a) ? max : a;
    min = (min < a) ? min : a;
  }
  int r = max - min + 1 - u;
  cout << r;
  return 0;
}
