#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n;
const int nMax = 3000 + 9;
int A[nMax];
int main() {
  read_file();
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &A[i]), A[i] -= i;
    priority_queue<pair<int, long long> > PQ;
    PQ.push(make_pair(-(1000000000), 0));
    int last = A[0];
    long long cost = 1;
    long long ans = 0;
    for (int i = 1; i < n; i++) {
      if (A[i] == last) {
        cost++;
      } else if (A[i] > last) {
        PQ.push(make_pair(last, cost));
        last = A[i];
        cost = 1;
      } else {
        while (true) {
          if (cost > 1) {
            cost--;
            ans += last - A[i];
            PQ.push(make_pair(A[i], 2));
            break;
          }
          pair<int, long long> top = PQ.top();
          int mxH = top.first;
          long long delta = top.second;
          if (mxH < A[i]) {
            ans += (last - A[i]) * cost;
            last = A[i];
            cost++;
            break;
          } else {
            ans += (last - mxH) * cost;
            last = mxH;
            cost += delta;
            PQ.pop();
            if (last == A[i]) {
              cost++;
              break;
            }
          }
        }
      }
    }
    printf("%lld\n", ans);
  }
}
