#include <bits/stdc++.h>
using namespace std;
const int N = 3100;
const int inf = 2147483647;
inline int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
int v[N], st[N], siz[N], del[N], lc[N], rc[N];
inline int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (v[x] < v[y]) swap(x, y);
  siz[x] += siz[y];
  rc[x] = merge(rc[x], y);
  if (siz[rc[x]] > siz[lc[x]]) swap(lc[x], rc[x]);
  return x;
}
int main() {
  int n = gi(), i, top = 0, k, t;
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    v[k = i] = gi() - i;
    siz[k] = 1;
    while (top && v[k] < v[st[top]]) {
      t = merge(st[top], k);
      del[t] = del[k] + del[st[top--]];
      k = t;
      while (siz[k] > del[k] + 1)
        t = merge(lc[k], rc[k]), del[t] = del[k] + 1, k = t;
    }
    st[++top] = k;
  }
  for (i = 1, n = 0; i <= top; i++)
    for (k = st[i], siz[k] += del[k]; siz[k]--;) ans += abs(v[++n] - v[k]);
  cout << ans << endl;
  return 0;
}
