#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
int h[maxn], a[maxn], n;
long long f[maxn], g[maxn], mn;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &h[i]), a[i] = h[i] - i;
  sort(a + 1, a + n + 1);
  for (int i = (1); i <= (n); i++) f[i] = abs(h[1] - (a[i] + 1));
  for (int i = (2); i <= (n); i++) {
    for (int j = (1); j <= (n); j++) g[j] = f[j];
    memset(f, 0x3f, sizeof f);
    mn = 2e18;
    for (int j = (1); j <= (n); j++) {
      mn = min(mn, g[j]);
      f[j] = mn + abs(h[i] - (a[j] + i));
    }
  }
  mn = 2e18;
  for (int i = (1); i <= (n); i++) mn = min(mn, f[i]);
  printf("%I64d\n", mn);
  return 0;
}
