#include <bits/stdc++.h>
using namespace std;
long long s[3200][3200];
int g[3200], t[3200];
int i, j, n, l, r, mid;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &g[i]), g[i] = g[i] + n - i, t[i] = g[i];
  sort(t + 1, t + n + 1);
  for (i = 1; i <= n; i++) s[i][0] = 1000000000000000LL;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      s[i][j] = min(s[i][j - 1], s[i - 1][j] + abs(g[i] - t[j]));
  printf("%I64d", s[n][n]);
  return 0;
}
