#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 3e3 + 10;
int a[maxn], b[maxn];
long long dp[maxn][maxn];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      a[i] -= i;
      b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    memset(dp, 0, sizeof(dp));
    for (long long i = 1; i <= n; ++i) {
      long long minn = dp[i - 1][1];
      for (int j = 1; j <= n; ++j) {
        minn = min(minn, dp[i - 1][j]);
        dp[i][j] += minn + abs(a[i] - b[j]);
      }
    }
    long long ans = dp[n][1];
    for (int i = 2; i <= n; ++i) ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}
