#include <bits/stdc++.h>
using namespace std;
long long dp[3001][3001];
int main() {
  ios::sync_with_stdio(false);
  ;
  long long i, j, k, l, r, m, n, o, t, arr[3001], sor[3001];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] -= i;
    sor[i] = arr[i];
  }
  sort(sor + 1, sor + n + 1);
  for (j = 1; j <= n; j++) {
    if (arr[1] > sor[j])
      dp[1][j] = abs(arr[1] - sor[j]);
    else
      dp[1][j] = 0;
  }
  for (i = 2; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (j > 1)
        k = dp[i][j - 1];
      else
        k = 9000000000000000000;
      o = dp[i - 1][j] + abs(arr[i] - sor[j]);
      dp[i][j] = min(o, k);
    }
  }
  long long ans = 9000000000000000000;
  for (j = 1; j <= n; j++) {
    ans = min(ans, dp[n][j]);
  }
  cout << ans << endl;
}
