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