#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define INF 2000000000
#define MAX 300000
using namespace std;

int main(){
    vector<int> v1;
    int sum = 0,n,b;
    cin >> n;
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        v1.push_back(x);
    }
    vector<int> v2 = v1;
    sort(v1.begin(),v1.end());
    if(n % 2 == 0)
        b = (v1[(n/2)-1] + v1[n/2] - n + 1)/2;
    else
        b = v1[n/2] - n / 2 - 1;
    for(int i = 0;i < n;i++){
        sum += abs(v2[i] - (b + (i+1)));
    }
    cout << sum << endl;

    return 0;
}