#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long a[1000];
  cin >> n;
  cin >> a[0];
  long max = a[0], min = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
    } else if (a[i] < min) {
      min = a[i];
    }
  }
  cout << max - min - (n - 1);
  return 0;
}
