#include <bits/stdc++.h>
int main(void) {
  int n;
  scanf("%d", &n);
  int min = INT_MAX;
  int max = INT_MIN;
  int a;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (min > a) {
      min = a;
    }
    if (max < a) {
      max = a;
    }
  }
  printf("%d\n", (max - min + 1 - n));
}
