#include <bits/stdc++.h>
using namespace std;
int a[3005], b[3005];
long long dp[3005][3005];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      a[i] -= i;
      b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int len = unique(b + 1, b + 1 + n) - b - 1;
    long long mine;
    for (int i = 1; i <= n; i++) {
      mine = 9223372036854775807;
      for (int j = 1; j <= len; j++) {
        mine = min(dp[i - 1][j], mine);
        dp[i][j] = abs(a[i] - b[j]) + mine;
      }
    }
    mine = 9223372036854775807;
    for (int i = 1; i <= len; i++) mine = min(dp[n][i], mine);
    printf("%lld\n", mine);
  }
}
