#include <bits/stdc++.h>
using namespace std;
const int seed = 131;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n;
long long a[maxn], b[maxn];
long long mi[3005];
long long dp[3004][3005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  int tot = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= tot; j++) {
      dp[i][j] = 1e18;
      dp[i][j] = min(dp[i][j], mi[j] + abs(a[i] - b[j]));
    }
    mi[0] = 1e18;
    for (int j = 1; j <= tot; j++) mi[j] = min(mi[j - 1], dp[i][j]);
  }
  long long MIN = 1e18;
  for (int i = 1; i <= tot; i++) {
    MIN = min(MIN, dp[n][i]);
  }
  printf("%lld\n", MIN);
  return 0;
}
