#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 20;
const long long inf = 2e16;
long long n, a[N], b[N];
long long dp[N][N];
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]), a[i] -= i, b[i] = a[i];
    sort(b + 1, b + 1 + n);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) dp[i][j] = inf;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      long long mn = inf;
      for (int j = 1; j <= n; j++) {
        mn = min(mn, dp[i - 1][j]);
        dp[i][j] = mn + abs(a[i] - b[j]);
      }
    }
    long long ans = inf;
    for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}
