#include <bits/stdc++.h>

#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
#define mem(x, n) memset(x, n, sizeof(x))

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int SIZE = 2e5+10;

const ll MOD = 1e9 + 7;
ll n;
ll A[SIZE];

ll check(ll b) {
	ll s = 0;
	for(int i=0;i<n;i++) {
		s += abs(A[i] - (b + i + 1));
	}
	return s;
}

int main() {
	scanf("%lld", &n);
	for(int i=0;i<n;i++) {
		scanf("%lld", &A[i]);
	}
	ll l = -2e9, r = 2e9, m1, m2, c1, c2, ans;
	for(int i=0;i<200;i++) {
		m1 = l + (r-l)/3;
		m2 = l + (r-l)*2/3;
		c1 = check(m1);
		c2 = check(m2);
		if(c1 < c2) {
			ans = c1;
			r = m2;
		} else {
			ans = c2;
			l = m1;
		}
	}
	printf("%lld\n", ans);
}