#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
int n;
long long a[N], b[N], f[N][N];
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%lld", &a[i]), a[i] = b[i] = a[i] - i;
  sort(b + 1, b + n + 1);
  int c = unique(b + 1, b + n + 1) - (b + 1);
  for (int i = (1); i <= (n); ++i) f[i][0] = INF;
  for (int i = (1); i <= (n); ++i) {
    long long val = f[i - 1][0];
    for (int j = (1); j <= (c); ++j) {
      val = min(val, f[i - 1][j]);
      f[i][j] = val + abs(a[i] - b[j]);
    }
  }
  long long ans = INF;
  for (int i = (1); i <= (c); ++i) ans = min(ans, f[n][i]);
  printf("%lld\n", ans);
  return 0;
}
