#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int a[200005];
long long f(long long b)
{
long long int s=0;
for(int i=0;i<n;i++)
{
s+= abs(a[i]-(b+i+1));
}
return s;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
long long l=-1000000000,r=1000000000,m,res,v1,v2,v3;
while(l<=r)
{
m= (l+r)/2;
v1 = f(m-1);
v2= f(m);
v3 = f(m+1);
if(v2<=v1 && v2<=v3)
{
res = m;
r=m-1;
}
if(v2<=v1 && v3<=v2)
{
l=m+1;
}
else
if(v1<=v2 && v2<=v3)
{
r=m-1;
}
}
cout<<f(res)<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoJbG9uZyBsb25nIGludCBuOwoJbG9uZyBsb25nIGludCBhWzIwMDAwNV07Cglsb25nIGxvbmcgZihsb25nIGxvbmcgYikKCXsKCQlsb25nIGxvbmcgaW50IHM9MDsKCQlmb3IoaW50IGk9MDtpPG47aSsrKQoJCXsKCQkJcys9IGFicyhhW2ldLShiK2krMSkpOwoJCX0KCQlyZXR1cm4gczsKCX0KaW50IG1haW4oKQp7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoTlVMTCk7Cgljb3V0LnRpZShOVUxMKTsKCgljaW4+Pm47CgoJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCQljaW4+PmFbaV07Cgl9Cglsb25nIGxvbmcgbD0tMTAwMDAwMDAwMCxyPTEwMDAwMDAwMDAsbSxyZXMsdjEsdjIsdjM7Cgl3aGlsZShsPD1yKQoJewoJCW09IChsK3IpLzI7CgkJdjEgPSBmKG0tMSk7CgkJdjI9IGYobSk7CgkJdjMgPSBmKG0rMSk7CgkJaWYodjI8PXYxICYmIHYyPD12MykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcmVzID0gbTsKICAgICAgICAgICAgICAgIHI9bS0xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKHYyPD12MSAmJiB2Mzw9djIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGw9bSsxOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgaWYodjE8PXYyICYmIHYyPD12MykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcj1tLTE7CiAgICAgICAgICAgIH0KCX0KCQoJY291dDw8ZihyZXMpPDxlbmRsOwogICAgcmV0dXJuIDA7Cn0=