#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 100;
int a[maxn], b[maxn];
long long dp[maxn][maxn];
long long maxv[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(a, a + n);
  int tot = unique(a, a + n) - a;
  for (int i = 0; i < tot; ++i) {
    dp[0][i] = abs(b[0] - a[i]);
    if (i == 0)
      maxv[i] = dp[0][i];
    else
      maxv[i] = min(dp[0][i], maxv[i - 1]);
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < tot; ++j) {
      dp[i][j] = abs(b[i] - a[j]) + maxv[j];
      if (j == 0)
        maxv[j] = dp[i][j];
      else
        maxv[j] = min(maxv[j - 1], dp[i][j]);
    }
  }
  long long ans = 1e18 + 1;
  for (int i = 0; i < tot; ++i) ans = min(ans, dp[n - 1][i]);
  cout << ans << endl;
  return 0;
}
