#include <bits/stdc++.h>
using namespace std;
int n, a[3005], b[3005];
long long f[3005][3005], mn, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) f[1][i] = abs(b[1] - a[i]);
  for (int i = 2; i <= n; i++) {
    mn = 1e14;
    for (int j = 1; j <= n; j++) {
      mn = min(mn, f[i - 1][j]);
      f[i][j] = mn + abs(b[i] - a[j]);
    }
  }
  ans = 1e14;
  for (int i = 1; i <= n; i++) ans = min(ans, f[n][i]);
  printf("%lld", ans);
}
