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