#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll modpow(ll i, ll j) {
  ll tmp = 1;
  while (j) {
    if (j % 2) tmp = ((tmp * i) % (ll)(1e9 + 7));
    i = ((i * i) % (ll)(1e9 + 7));
    j /= 2;
  }
  return tmp;
}
int main() {
  int N;
  vector<int> A;
  cin >> N;
  A.resize(N);
  for (size_t i = 0; i < (N); i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int ans = 0;
  int before = 0;
  for (auto item : A) {
    if (before == 0) {
      before = 2;
    } else if (before != item) {
      ans += abs(before - item);
    }
    before = item;
  }
  cout << (ans) << endl;
  ;
}
