#include <bits/stdc++.h>
using namespace std;
int n;
long long b[3005], a[3005];
long long d[3005][3005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    a[i] = a[i] - i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    long long minn = trunc(1e18);
    for (int j = 1; j <= n; j++) {
      minn = min(minn, d[i - 1][j]);
      d[i][j] = minn + abs(a[i] - b[j]);
    }
  }
  long long kq = d[n][1];
  for (int i = 1; i <= n; i++) kq = min(kq, d[n][i]);
  cout << kq;
}
