#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
const int maxn = 3010;
long long a[maxn], b[maxn];
struct BIT {
  long long num[maxn];
  void init() {
    for (int i = 0; i < maxn; i++) num[i] = inf;
  }
  int low_bit(int x) { return x & (-x); }
  void update(int x, long long n) {
    while (x < maxn) {
      num[x] = min(num[x], n);
      x += low_bit(x);
    }
  }
  long long query(int x) {
    long long ans = inf;
    while (x) {
      ans = min(ans, num[x]);
      x -= low_bit(x);
    }
    return ans;
  }
} bi;
long long dp[2][maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]), a[i] -= i, b[i] = a[i];
  sort(b, b + n);
  int len = unique(b, b + n) - b;
  int cur = 0;
  for (int i = 0; i < n; i++) dp[cur][i] = abs(a[i] - a[0]);
  for (int i = 1; i < n; i++) {
    bi.init();
    for (int j = 0; j < n; j++) {
      if (dp[cur][j] == inf) continue;
      int pos = lower_bound(b, b + len, a[j]) - b + 1;
      bi.update(pos, dp[cur][j]);
    }
    cur ^= 1;
    for (int j = 0; j < n; j++) {
      dp[cur][j] = inf;
      int pos = lower_bound(b, b + len, a[j]) - b + 1;
      long long q = bi.query(pos);
      if (q != inf) dp[cur][j] = q + abs(a[j] - a[i]);
    }
  }
  long long ans = inf;
  for (int i = 0; i < n; i++) ans = min(ans, dp[cur][i]);
  printf("%lld\n", ans);
  return 0;
}
