#include <bits/stdc++.h>
using namespace std;
long long a[3005];
long long b[3005];
long long dp[3005][3005];
int main() {
  long long n, m, i, j, k, ans, num, sum, minn;
  while (~scanf("%lld", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      a[i] -= i;
      b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    for (i = 1; i <= n; i++) dp[1][i] = abs(a[1] - b[i]);
    for (i = 2; i <= n; i++) {
      minn = 1e18;
      for (j = 1; j <= n; j++) {
        minn = min(minn, dp[i - 1][j]);
        dp[i][j] = minn + abs(a[i] - b[j]);
      }
    }
    ans = 1e18;
    for (i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
    printf("%lld\n", ans);
  }
  return 0;
}
