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