#include <bits/stdc++.h>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 1000010
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);
//ios_base::sync_with_stdio(false);
 //cin.tie(NULL);
//Code starts from here......
int n;
int a[200100];

ll ans = 1e18;

ll cal(ll mid){

    ll minu = mid, sum = 0;

    for(int i=0; i<n; i++, minu++) sum += abs(a[i]-minu);
        
   // cout<<"M  "<<mid<<"  "<<sum<<endl;

    return sum;
}

ll Turn(ll left , ll right){

    while(left <= right){

        ll mid1 = left+( (right-left)/3 );
        ll mid2 = mid1+( (right-left)/3 );

        ll tot1 = cal(mid1);
        ll tot2 = cal(mid2);

        if(tot1 < tot2){

            right = mid2-1;
            ans = min(ans,tot1);
        }
        else if(tot1>=tot2){

            left = mid1+1;
            ans = min(ans,tot2);
        }
        //cout<<"  "<<mid1<<" "<< tot1<<"  "<<mid2<<"  "<<tot2<<endl;

        //cout<<">>>>>>>>>>>>>>>>>>>>>"<<"  "<<left<<"  "<<right<<endl;

    }

}
int main(){

    scanf("%d",&n);

    for(int i=0; i<n; i++){

        scanf("%d",&a[i]);

    }

    Turn(-1e9,0LL);
    ll ans1 = ans;

    ans = 1e18;
    Turn(0LL,1e9);
    ll ans2 = ans;

    cout<<min(ans1,ans2)<<endl;

    return 0; 
}



Measured memory_bytes: 1024