#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const long long SZ = 3010, SSZ = 12, INF = 0x7FFFFFFFFFFFFFFF, mod = 100000000;
long long n, arr[SZ], dp[SZ][SZ], b[SZ];
void init() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> arr[i], arr[i] -= i;
    b[i] = arr[i];
  }
  sort(b + 1, b + 1 + n);
}
void work() {
  long long res = INF;
  for (long long i = 1; i <= n; ++i) {
    long long minv = INF;
    for (long long j = 1; j <= n; ++j) {
      minv = min(minv, dp[i - 1][j]);
      dp[i][j] = minv + abs(b[j] - arr[i]);
      if (i == n) res = min(res, dp[i][j]);
    }
  }
  cout << res << endl;
}
int main() {
  long long casenum;
  {
    init();
    work();
  }
  return 0;
}
