/**
Polina
              ,;;:   ,,.    ,.sssriisi  ,.; SS555s322XXrr;,;::;;;rsSsr93hhhhhhhh9hX5X5sXis:...
           .:::;r:    :...:;;rsii5 ,   .s:52S2sSrs5222iSs;,;:;.;:sirs:hhh9993h9hhGh9X5Ss,,:i Ss.
           ,,;:;r    ;s; .  . .  ,r;  r;s;;iS5:.;;S322Sr;;:::;;:rs;s;ih99X5hhhhGh99X;:,rr5Si;s::
           ::;;:,   ,r       .   ;S,  s,,iirirs;:s5523h;;;r.rs,:,,r;iir9hhX99GhhhhXss;;;23X22Sr;:.
            ;;r;:.  ir           ;,  :srrriisSS99hh9hh9GG,;,r5;r,,;;,39hh9hG99hGhh99srsXhhX92S5SisS
          ;:;rrs:, ,  .     . .. ,;.,i:ssrii;5S95;9h9hhhhG9hSh. S,;;,:G9hX23hhGhh3995i5Xh932i52s55SS
        :;,;;rrss: i5i     ., ,,, ::;; .i;s;22;;sX3h9h9hh9hh:hh  3s;GiGh9X9r535hGh95XX9Gh3399XX5sis;.
 .    , :,,::r;ssr.Sis     . .::;.sr52 ,,;SS5SssiiS2S399993hhhhhhhhGGGhhh953hhhhh99XX3GGG9h599S5rSsr5
  ,., ,,: ,,:s:;rsSSSii   . .,:,;SSsisr rr;rr;;;;:;rsS5X33999hhhhhGhGGG&2h9X39Xh9hhh9G&Gh3GGG9i55SSsS..
 ....,,,.  ..rs,sr;iiiss r   rs,:;rsr::...,.,,.,,,,:;ssS5X3999hhhhhhGG:XGG39X9h9GGGGGGG39G&Gh25iS5SsS,....   .
  .  ..      ;rs :srssrssr;r ;sss;:,              ..,:;riSXX399h9hhGhhGGG&,h939h&&&GGG&&GGGGh9XSS5Ss,,,,.....:
     ....     ;r   ;s;;;r::::::;,:.                ..,,;riS5333hhhhhGGGGG&G&X2hSGhGGG&&G&hhGiiS5225srsSSSS2X33
         ,:; ;;     ,;;;;::,:.:::                   ..,::;i55339hhhhGGGGGGGGG99h933G&&GGG&&G55533SS9h99999993X
          ,::,         :;;;,,.:.                     ..,:;rsS5339hhhhGGGGGGh3293h&GG&&&&&GGGSG3Shhh93XX3X33X2;
          .,.,.       .:;;;;,. .                      .,,:;rsS5399hhGhGGGhGGGGhXhhG&&&&GGGG&GGGh9352SXr:r9332
                      ,:;;;:,,,.                       ..,:;;ss593XhhhGGGGG&&G33hG&G&&&&&h&GG&G3h99h353XiX993:
           ...        ,,.;,,::..                      ,,,,::;rri2h93GhGGGGGGGhX99G9&&&&&G&G&&h9h5hh3h9h35sh992
            .         .  . .:,.                     ...,,:;;;riS5X9h9GhGGGG&G&GhGG&&&&&&&&GG&G9G3s2323322sh933
                      .    ,,..                     .,::::;si22X392393hhGG&G&&&&&&G&&&&&&GGGhhG9X29h395srr9993
                           ...                     ..:;;s222XX2XSSi2999hG&G&G&&&G&h&&G&&G&&GGhG9XG3hX2ssrr2hh9
                           ....                   ..,:rssiS555iiiSS2X3hhhhGGGGG&&&h&&&&&&GG&GGGGGG932Ssssrihh3
                          ,,,...                  .,:;rsiS5555XhhGhGh39hhhhGGG&GG&&&G&&&&&&&GGGG39X2Xh5sssshh9
                          ,:;rsisssirs;:,,,.      .,:riS52239GG399rs5XX9hhGGGGGG&GGh&&&&GG&GGG99352SSsSisiiXhh
                          ,;siSSSSsssr;:,,,,.     .:;i52XXX3h933X9sri223hhhhGGGG&G&&&G&GGGG&GGh9332255SiiisShh
                         ..;rsrrrrssisrrrrr;,.    ..;i2X3X233i393r:;S2329hhhhhGGG&GG&GG&&&G&GGGh33X3S55SSSSSGh
                         .r;iSS2333X3X55Sissr:     .rs2332s3X5SssiSX2339S9h99hhGGh&GGGG&G&GGGGGG999XX255iS52Gh
                         .rs5X39335X, ,;siisr;:     ,sSX335issssissS522XXX9939hGGGGGGGGGGGGGGGGGh999hh9h&GGGGG
                          si2X3X33XX:..,ri;r, ,     .:i5X3X5irrsrsrssiSsi593933hhGG&GGGGG&&GGGGGGGhGhGhhGGhGh3
                          siSX2XX53i:;r;s;:;,..      ,;52225Ssr;r;rrrrrrrr29X339hGGGGG&h&G&GGGGGGGGG39XSSS5255
                      , . rsiSS2XX225iis:,,, .       .;S52255ir;:::;:::;:;sX9399hGGGGG&GG&G&GGGGGGGh9993X2XX55
                        .;rriiS55Siisr;,,..           :s55252Sir;:,,,.:,::;sX939hhhGGGG&&G&&&&GGGGGGh399222225
                        ;;sssiSSSissr;,,. .           ,rS22225Ss;::,,.,,::;sS3999hhGG&GGG&GG&&&GGGGhGh939X22X2
                        ;;iisiSSSisr;::..             ,rs2XX2XSsr:,....,,:rsS5999GhGGGGGGGGGG&&&GGGGhh939XX222
                       s ri2iSSSiisr;:,..              ;s52XX33S;;,...,,:;;iS2X99hGhGGGGGG&&&G&&&GGGGGh999X322
                       ;;sSXiSSSiir;;,,...             :;S5XXXX35r,,,.,:;;riS233h3hGhGGG&GG&&G&&&&GGGGh9h933XX
                        ss2XXS55Sis;;:,..               :s5222232i:,,.,,;rrS5X3999hhhGGGG&G&GG&GG&GGGGGG9h933X
          ,. : ;;      :ri2233S5Sisr;,..               .;S55S5532ir,,,,:;rS52X9h39hG9GGGGGGGG&GGG&&GGGGGGhh33X
    .,:;;:r:..  r     .r;s22XX325Srr::..               ,;iXX3XX5Sir;;:,;riS2X39h99GhGhGGGGGGGG&&&G&&&GGGGhh933
 :,,;:::::;;: .       ,rr5X2XXX3SSss;:.. . .     ,is;.,;s55X25SSisss;;;rsS523399hGhGhGGhhGGGGGGGG&&&&GGGGhG99h
,.,:,                 r;S5X2XX3X3sSsr:,.....            ,:rssiiiSiSisisiS52X3399hGG9GGhh9GGGGGGGG&G&G&G&GGGhGG
                     ,::i55XXXX333;iir:,,...            ..,:riiiS5S5issS522XX39hGhGG3hGhGhGGG&&GGG&G&GGGGGGGGG
                    .,;sS5X5XX3333X,iis;:,,..           ...,r5555XGh35SSS22XX399hG&99hGh9GhGGG&&&G&&&GGGGGGGGG
                    ,;s;s5222XXX33X3:;ss;;:,,,,,,.    .. ,;S5X339X3X255SSS2XX399h&hX99hh9GhhGGG&&&&&&&G&GGGGGG
                    .:;Sii5252XXX3X33Xr;rrr;:::;ss5SiS2SiiiSii5S22255255222X339hGG&X939hhhG9XGGG&G&&&G&&GGGGGG
                     ;;S iS2252XX333XX9rrrrr;r;rss;:;:,..,,;rrrsSS22225222X339hhGGG9hhGGGhGGGhGG&G&G&&&&&&G&GG
                   .:.:55siS5222233333333rssr;rrrr::..   ,,:rrsiSS552X222XX39hhGGhGhGhGhGG3G&hhGG&GG&&&G&&&G&&
                    ssr,Ss:;SXS2XXX33933939ssssr;;;::,,,;rss;rriiSS5S2X2XX39hhhGhhhhGhGGhGGh&GGh&GG&&&&&GGGGG&
                  ,:sr .iiiiS2222XXX33333999hSis;;::::::,.,::;rrssiiS52XX33hhhhhGGhhGG&9Ghhh&X&hGGG&GG&&&GG&GG
                 ..,::;r,i;si5252X2X93339399hhhhsr;;:,.. .,:;;rrsiiSS52XX999h9hhhG93GhhGGGh&&G3G&GG&&&&&&&&G&&
                   r  s:,SiSSi552XX2X33399999hhhhGir;:,,,:::;;rssiiiS52X399999hhhhGX9G9G3GGh&GGGhGGG&&G&&G&&&&
                .. r:,r.is;r5sS25525X33339hhh9hhhhhh9s;::;:;rsrssiS55XXX33333999hhG2S99G9G&GhGG&GGG&&&G&&G&&&G
          :r,;  :, s srr ;iriii5552X2X339999hhhhhhhh9932irrissS5552522XXXXXX333399GhSS9hG9G&hGGGGGG&&&&&&G&&&&
  .:;r;r;.;:  ,..:    ;r,;;sriri5SXX2X33999939hhhhhhh93X225255S55555555522XXXX9999hGXSXhGGG&&GGGhGGGG&&&&&&&&&
 ;;:.::.:        ,  ;,s:s s;s:sSs553XXX333999999hhhhh9333X55555SSSSSSS5522222X33339hG9299Gh&G&&GGGG&&G&&&&&&GG
               . ,, i..:,,;;s;srS5S2XXX333993933hhhh999332255555555SSS55552222333339GG3X9GG&&&G&GGGG&GG&&&&&G&
                  .  ,:;.;,;rs:rSiS533333339393999hh99333X2255SSSiSS5255555552X39333GGGh39GG&GGGGGG&&&&&&&&&&&
                  :..s. :,;;;;rrisSXSXX3333939X3h99999333XX225555SSSSS5S555555399999hGGGh9G&G&G&GGG&G&G&&&&&&&
                   :.,; ;;:,:r;;rsSSXXX33339332399hh99333XX22522255SSSS5SSSSS5X393939399939hGGh&&GG&&&&&&&&&&
**/
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define left left228
#define right right228
#define x1 x1228
#define y1 y1228
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
mt19937 randint(1423434);

const int maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18; 
const double eps = 1e-9, pi = acos(-1);
int n, cnt[maxn]; 
            
void solve() {                                  
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> cnt[i]; 
		cnt[i] -= (i + 1); 
	} 	
	sort(cnt, cnt + n); 
	int p1 = cnt[n / 2]; 
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += abs(cnt[i] - p1);  	
	}
	cout << ans; 
}                               

signed main() {
//	freopen("turtles.in", "r", stdin);
//    freopen("turtles.out", "w", stdout);
    #ifdef offline_judge
        freopen("TASK.in", "r", stdin);
        freopen("TASK.out", "w", stdout);
    #endif
    srand(228);
    cout.precision(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	solve();
    return 0;
}
                               

Measured memory_bytes: 1792