#include <bits/stdc++.h>
using namespace std;
int N;
long long f[3005];
long long c[3005];
long long dp[3005][3005];
long long qzh[3005];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%I64d", &f[i]);
    f[i] -= i;
    c[i] = f[i];
  }
  sort(c + 1, c + N + 1);
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 1; i <= N; i++) {
    if (i == 1)
      memset(qzh, 0, sizeof(qzh));
    else
      memset(qzh, 0x3f, sizeof(qzh));
    for (int j = 1; j <= N; j++) qzh[j] = min(dp[i - 1][j], qzh[j - 1]);
    for (int j = 1; j <= N; j++) dp[i][j] = qzh[j] + abs(f[i] - c[j]);
  }
  long long ans = 0X7FFFFFFFFFFFFFFF;
  for (int i = 1; i <= N; i++) ans = min(dp[N][i], ans);
  printf("%I64d", ans);
  return 0;
}
