#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
using ll = long long;
ll a[maxn]{0}, b[maxn]{0}, f[maxn][maxn]{0};
int main(void) {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      a[i] -= i, b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int m = unique(b + 1, b + 1 + n) - b - 1;
    memset(f, 0x3f, sizeof f);
    for (int i = 1; i <= m; ++i) f[1][i] = min(f[1][i - 1], abs(a[1] - b[i]));
    for (int i = 2; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        f[i][j] = min(f[i][j - 1], abs(a[i] - b[j]) + f[i - 1][j]);
      }
    }
    printf("%I64d\n", f[n][m]);
  }
  return 0;
}
