#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3005;
long long F[MaxN], G[MaxN], A[MaxN], B[MaxN];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &A[i]);
  for (int i = 1; i <= n; ++i) A[i] -= i, B[i] = A[i];
  sort(B + 1, B + n + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) F[j] = G[j] + abs(A[i] - B[j]);
    G[1] = F[1];
    for (int j = 2; j <= n; ++j) G[j] = min(G[j - 1], F[j]);
  }
  printf("%I64d", G[n]);
  return 0;
}
