#include <bits/stdc++.h>
using namespace std;
int n;
int a[1 << 10];
int min_a = 1 << 30;
int max_a = 0 - (1 << 30);
int AnswerProblem;
void read(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
}
void solve(void) {
  for (int i = 0; i < n; i++) {
    min_a = min(min_a, a[i]);
    max_a = max(max_a, a[i]);
  }
  AnswerProblem = (max_a - min_a + 1) - n;
}
void print(void) { cout << AnswerProblem << endl; }
int main() {
  read();
  solve();
  print();
  return 0;
}
