#include <bits/stdc++.h>
using namespace std;
int hg[30004];
int hgmi[30004];
int idx[300004];
int cmp(int x, int y) { return hgmi[x] < hgmi[y]; }
long long dp[30004];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    scanf("%d", hg + i);
  }
  for (int i = 0; i < (n); i++) hgmi[i] = hg[i] - i;
  for (int i = 0; i < (n); i++) idx[i] = i;
  sort(idx, idx + n, cmp);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      dp[j] += abs(hgmi[j] - hgmi[i]);
    }
    long long mn = (long long)1e18;
    for (int j = 0; j < (n); j++) {
      mn = min(dp[idx[j]], mn);
      dp[idx[j]] = mn;
    }
  }
  long long res = (long long)1e18;
  for (int i = 0; i < (n); i++) {
    res = min(res, dp[i]);
  }
  cout << res << endl;
}
int main() {
  solve();
  return 0;
}
