#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int a[N], b[N];
long long dp[N][N];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      a[i] -= i;
      b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    dp[0][1] = 0;
    for (int i = 1; i <= n; i++) {
      long long mn = dp[i - 1][1];
      for (int j = 1; j <= n; j++) {
        mn = min(mn, dp[i - 1][j]);
        dp[i][j] = abs(a[i] - b[j]) + mn;
      }
    }
    long long ans = dp[n][1];
    for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
    printf("%I64d\n", ans);
  }
  return 0;
}
