unittest
{
	assert( [ "5", "2 2 3 5 5" ].solve == 2 );
	assert( [ "9", "1 2 3 4 5 6 7 8 9" ].solve == 0 );
	assert( [ "6", "6 5 4 3 2 1" ].solve == 18 );
	assert( [ "7", "1 1 1 1 2 3 4" ].solve == 6 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	// 式変形：abs( as[i] - ( b + ( i + 1 ) ) ) == abs( as[i] - ( i + 1 ) - b )
	foreach( i, ref a; as )
	{
		a -= 1 + i.signed;
	}
	
	// 各aからの距離の合計を最小にするにはbをasの中央値にすればいい
	auto ans = 0L;
	as.sort();
	if( n % 2 )
	{
		auto t = 0L;
		auto b = as[ $ / 2 ];
		foreach( ref a; as )
		{
			t += abs( a - b );
		}
		ans = t;
	}
	else
	{
		auto t1 = 0L;
		auto t2 = 0L;
		auto b1 = as[ $ / 2 - 1 ];
		auto b2 = as[ $ / 2 ];
		foreach( ref a; as )
		{
			t1 += abs( a - b1 );
			t2 += abs( a - b2 );
		}
		ans = min( t1, t2 );
	}
	return ans;
}
