#include <bits/stdc++.h>
using namespace std;
long long n, pos, ans = 10000000000000000;
long long a[3000 + 5], b[3000 + 5], f[3000 + 5][3000 + 5], Min[3000 + 5];
long long read() {
  char c;
  long long x = 0, f = 1;
  c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i) a[i] = read() - i, b[i] = a[i];
  sort(b + 1, b + n + 1);
  pos = unique(b + 1, b + n + 1) - b - 1;
  for (register long long i = 1; i <= n; ++i) {
    for (register long long j = 1; j <= pos; ++j)
      f[i][j] = Min[j] + abs(a[i] - b[j]);
    Min[0] = 10000000000000000;
    for (register long long j = 1; j <= pos; ++j)
      Min[j] = min(Min[j - 1], f[i][j]);
  }
  for (register long long i = 1; i <= pos; ++i) ans = min(ans, f[n][i]);
  printf("%lld", ans);
  return 0;
}
