#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
const long long INF = 1e18;
long long f[maxn][maxn];
int a[maxn], b[maxn];
int N;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &a[i]), a[i] -= i + 1, b[i] = a[i];
  sort(b + 1, b + N + 1);
  for (int i = 0; i <= N; i++)
    for (int j = 0; j <= N; j++) f[i][j] = INF;
  for (int i = 0; i <= N; i++) f[0][i] = 0ll;
  for (int i = 1; i <= N; i++) {
    long long mini = INF;
    for (int j = 1; j <= N; j++) {
      mini = min(mini, f[i - 1][j]);
      f[i][j] = mini + (long long)abs(a[i] - b[j]);
    }
  }
  long long ans = INF;
  for (int i = 1; i <= N; i++) ans = min(ans, f[N][i]);
  printf("%lld", ans);
  return 0;
}
