#include <bits/stdc++.h>
using namespace std;
int num[1001] = {0};
int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> num[i];
  sort(num, num + n);
  sum = num[n - 1] - num[0] + 1 - n;
  cout << sum << endl;
}
