#include <bits/stdc++.h>
using namespace std;
long long n, ans, arr[300005];
int main() {
  scanf("%I64d", &n);
  set<long long> exist;
  map<long long, int> dup;
  for (long long i = 1; i <= n; i++) exist.insert(i);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &arr[i]);
    dup[arr[i]]++;
    exist.erase(arr[i]);
  }
  sort(arr, arr + n);
  int en = n - 1;
  while (arr[en] > n) {
    auto it = prev(exist.end());
    ans += abs(arr[en] - *it);
    exist.erase(it);
    en--;
  }
  for (int i = 0; i <= en; i++) {
    if (arr[i] <= 0) {
      auto it = exist.lower_bound(1);
      ans += abs(*it - arr[i]);
      exist.erase(it);
    } else if (dup[arr[i]] > 1) {
      auto it = exist.lower_bound(1);
      ans += abs(*it - arr[i]);
      exist.erase(it);
      dup[arr[i]]--;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
