#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

bool Debug;

const int mod = 1e9+7;
const int MAXN = 1e5+7;

#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define iter iterator
#define sqr(a) ((a)*(a))
#define abs(a) ((a)>0?(a):(-(a)))
#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define lop(i,a,b) for(int i = (a); i <= (b); ++i)
#define dlop(i,a,b) for(int i = (a); i >= (b); --i)
#define debu(...) if (Debug) fprintf(stderr, __VA_ARGS__)
#define debug(x) if (Debug) cerr << "" #x " = " << x << endl
#define ergo(a) for(auto it = a.begin(); it != a.end(); ++it)

template<typename T> T gcd(T a, T b) {while(T t = a % b) a = b, b = t; return b;}
template<typename T> T Pow(T a, T b, T mod) {T ret = 1; for( ; b; b >>= 1) {if (b & 1) ret = ret * 1ull * a % mod; a = a * 1ull * a % mod;} return ret%mod;}
template<typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template<typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template<typename T> void amod(T &x, T y) {x += y; if (x >= mod) x -= mod;}
template<typename T> void smod(T &x, T y) {x -= y; if (x < 0) x += mod;}

typedef long long ll; 
typedef long double ld;
typedef unsigned int uint;
typedef pair<int ,int> pii;
typedef unsigned long long ull;

struct IO {
  static const int S = 5 << 20;int c, f;
  char wbuf[S], *p2, buf[S], *p1, *end;
  IO() {p1 = end = buf, p2 = wbuf;}
  int getc() {
    if(p1 == end)
      end = (p1 = buf) + fread(buf, 1, S, stdin);
    return p1==end?-1:*p1++;
  }
  template<typename T>void read(T &x) {
    f = 1, c = getc(), x = 0;
    while(c <= 32) (c=='-')&&(f = -1), c = getc();
    while(isdigit(c)) x = x * 10 + c - '0', c = getc();
    x *= f;
  }
  void get(char *s) {
    c = getc();
    while(c <= 32) c = getc();
    while(c > 32) *s++ = c, c = getc();
    *s = 0;
  }
  void put(int x) {
    if(p2-wbuf == S) 
      fwrite(wbuf, 1, S, stdout), p2 = wbuf;
    *p2++ = x;
  }
  template<typename T> void out(T x, int y) {
    if(x < 0) put('-'), x = -x;
    static int sta[24]; int n = 0;
    while(x || !n) sta[++n] = x % 10 + '0', x /= 10;
    while(n) put(sta[n--]); put(y);
  }
  void print(char *s, int y) {while(*s) put(*s++); put(y);}
  ~IO() {fwrite(wbuf, 1, p2-wbuf, stdout), p2 = wbuf;}
}io;

#define put io.put
#define get io.get
#define out io.out
#define print io.print
#define read(a) (io.read(a))
#define read2(a, b) (read(a), read(b))
#define read3(a, b, c) (read(a), read(b), read(c))
int n, a[200005];
int main() {
  #ifdef LOCAL_DEBUG
    Debug = 1;
    freopen("data.in", "r", stdin);
  #endif
  read(n);
  lop(i,1,n) read(a[i]), a[i] -= i;
  sort(a+1, a+n+1); 
  long long ans = 0;
  if (n & 1) {
    int mid = n/2; ++mid;
    mid = a[mid];
    for(int i = 1; i <= n; ++i) ans += abs(a[i]-mid);
  }
  else {
    int mid = n/2;
    mid = a[mid] + a[mid+1] >> 1;
    for(int i = 1; i <= n; ++i) ans += abs(a[i]-mid);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 5120