#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int x[n];
  long long int y[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    x[i] = x[i] - i;
    y[i] = x[i];
  }
  sort(y, y + n);
  long long int d[n][n];
  long long int dmin[n][n];
  for (int j = 0; j < n; ++j) {
    d[0][j] = abs(x[0] - y[j]);
    if (j == 0) {
      dmin[0][j] = d[0][j];
    } else {
      dmin[0][j] = min(dmin[0][j - 1], d[0][j]);
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      d[i][j] = abs(x[i] - y[j]) + dmin[i - 1][j];
      if (j == 0) {
        dmin[i][j] = d[i][j];
      } else {
        dmin[i][j] = min(dmin[i][j - 1], d[i][j]);
      }
    }
  }
  long long int Smin = 1000000000000000;
  Smin = min(Smin, dmin[n - 1][n - 1]);
  cout << Smin;
  return 0;
}
