#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000;
int n;
int aa[maxn + 5], bb[maxn + 5];
long long f[maxn + 5][maxn + 5];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", aa + i), aa[i] -= i, bb[i] = aa[i];
  sort(bb + 1, bb + 1 + n);
  for (int i = 1; i <= n; ++i) {
    long long mini = (long long)1 << 60;
    for (int k = 1; k <= n; ++k) {
      mini = min(mini, f[i - 1][k]);
      f[i][k] = abs(aa[i] - bb[k]) + mini;
    }
  }
  long long ans = (long long)1 << 60;
  for (int i = 1; i <= n; ++i) ans = min(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
