#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
typedef long long llong;

llong N, A[200050];


int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		A[i] -= (i + 1);
	}
	sort(A, A + N);

	llong tmp = 0;
	llong ans;
	for (int i = 0; i < N; i++)
	{
		tmp += A[i] - A[0];
	}
	ans = tmp;

	for (int i = 1; i < N; i++)
	{
		tmp -= (A[i] - A[i - 1]) * (N - 1 - i);
		tmp += (A[i] - A[i - 1]) * (i - 1);

		if (tmp < ans)
			ans = tmp;
	}

	cout << ans;
}