#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 10;
long long dp[maxn][maxn];
long long a[maxn], q[maxn];
long long MIN[maxn];
int n;
long long ABS(long long a) { return max(a, -a); }
bool cmp(const int& a, const int& b) { return a > b; }
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &q[i]);
      a[i] = q[i];
      q[i] = q[i] - i;
      a[i] = a[i] - i;
    }
    sort(q + 1, q + n + 1);
    memset(dp, -1, sizeof dp);
    memset(MIN, 0, sizeof MIN);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) dp[i][j] = MIN[j] + ABS(a[i] - q[j]);
      MIN[1] = dp[i][1];
      for (int j = 2; j <= n; j++) MIN[j] = min(MIN[j - 1], dp[i][j]);
    }
    long long ans1 = dp[n][1];
    for (int i = 2; i <= n; i++) ans1 = min(ans1, dp[n][i]);
    printf("%lld\n", ans1);
  }
  return 0;
}
