#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
const int nMax = 3000 + 1 + 9;
int midian[nMax][nMax];
long long cost[nMax][nMax];
int A[nMax], B[nMax];
int n;
long long dp[nMax];
int last[nMax];
void prepro() {
  for (int start = 1; start <= n; start++) {
    priority_queue<int> P;
    priority_queue<int, vector<int>, greater<int> > Q;
    long long sumP = 0, sumQ = 0;
    for (int i = start; i <= n; i++) {
      int minQ = Q.empty() ? -(2000000000) : Q.top();
      if (B[i] >= minQ) {
        Q.push(B[i]);
        sumQ += B[i];
        if (Q.size() == P.size() + 2) {
          int minQ = Q.top();
          Q.pop();
          sumQ -= minQ;
          P.push(minQ);
          sumP += minQ;
        }
      } else {
        P.push(B[i]);
        sumP += B[i];
        if (P.size() == Q.size() + 1) {
          int maxP = P.top();
          P.pop();
          sumP -= maxP;
          Q.push(maxP);
          sumQ += maxP;
        }
      }
      int mid;
      mid = Q.top();
      midian[start][i] = mid;
      long long costP = 1LL * P.size() * mid - sumP;
      long long costQ = sumQ - 1LL * Q.size() * mid;
      cost[start][i] = costP + costQ;
    }
  }
}
void build_dp() {
  dp[0] = 0, last[0] = -(2000000000);
  for (int j = 1; j <= n; j++) {
    dp[j] = LLONG_MAX;
    last[j] = +(2000000000);
    for (int i = 0; i < j; i++) {
      if (last[i] >= midian[i + 1][j] + (i + 1)) continue;
      long long nw = dp[i] + cost[i + 1][j];
      int nwl = midian[i + 1][j] + j;
      if (dp[j] > nw) {
        dp[j] = nw;
        last[j] = nwl;
      } else if (dp[j] == nw) {
        last[j] = min(last[j], nwl);
      }
    }
  }
}
int main() {
  read_file();
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &A[i]), B[i] = A[i] - i;
    prepro();
    build_dp();
    long long ans = dp[n];
    printf("%lld\n", ans);
  }
}
