#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const int mod = 1000000009;
using namespace std;
long long int n, a[3333], b[3333], pd[3333][3333];
int main() {
  cin >> n;
  for (int i = (int)(1); i < (int)(n + 1); ++i) cin >> a[i], b[i] = (a[i] -= i);
  sort(b + 1, b + n + 1);
  memset(pd, INF, sizeof pd);
  for (int i = (int)(1); i < (int)(n + 1); ++i) pd[0][i] = 0;
  for (int i = (int)(1); i < (int)(n + 1); ++i)
    for (int j = (int)(1); j < (int)(n + 1); ++j) {
      pd[i][j] = min(pd[i][j - 1], pd[i - 1][j] + abs(b[j] - a[i]));
    }
  cout << pd[n][n] << endl;
  return 0;
}
