#include <bits/stdc++.h>
#pragma GCC optimize(2, "inline", "Ofast")
using namespace std;
const int N = 1e4 + 500;
int n;
int a[N];
namespace Hp {
int val[N], fa[N], tmp[N << 1];
vector<int> G[N];
queue<int> Q;
int rt, tot;
void Init() {
  rt = tot = 0;
  for (int i = 1; i <= N; i++) Q.push(i);
}
int Merge(int x, int y) {
  if (val[x] < val[y]) swap(x, y);
  fa[y] = x;
  G[x].push_back(y);
  return x;
}
void Insert(int v) {
  if (!tot) {
    ++tot;
    rt = Q.front();
    Q.pop();
    val[rt] = v;
    fa[rt] = 0;
    return;
  }
  ++tot;
  int nd = Q.front();
  Q.pop();
  val[nd] = v;
  rt = Merge(rt, nd);
}
int Top() { return val[rt]; }
void Pop() {
  int l = 1, r = 0;
  tot--;
  for (int i = 0; i < (int)G[rt].size(); i++) {
    int to = G[rt][i];
    if (fa[to] == rt) tmp[++r] = to;
  }
  if (l > r) return;
  while (l < r) tmp[++r] = Merge(tmp[l++], tmp[l++]);
  rt = tmp[l], fa[tmp[l]] = 0;
}
}  // namespace Hp
priority_queue<int> Q;
int main() {
  Hp::Init();
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    x -= i;
    Hp::Insert(x);
    if (Hp::Top() > x) {
      ans += Hp::Top() - x;
      Hp::Pop();
      Hp::Insert(x);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
