#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, count = 0, d;
  cin >> a;
  int b[a];
  for (int i = 0; i < a; i++) {
    cin >> b[i];
  }
  sort(b, b + a);
  d = b[a - 1] - b[0];
  d = d + 1;
  count = d - a;
  cout << count << endl;
  return 0;
}
