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