#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
int a[maxn], b[maxn];
long long dp[maxn][maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  long long mmin = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    mmin = dp[i - 1][1];
    for (int j = 1; j <= n; j++) {
      mmin = min(mmin, dp[i - 1][j]);
      dp[i][j] = mmin + abs(b[j] - a[i]);
    }
  }
  mmin = dp[n][1];
  for (int i = 2; i <= n; i++) mmin = min(mmin, dp[n][i]);
  printf("%lld\n", mmin);
  return 0;
}
