#include <bits/stdc++.h>
using namespace std;
int n, a[3010], b[3010];
long long f[3010][3010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i] - i, a[i] -= i;
  sort(b + 1, b + 1 + n);
  int k = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) {
    long long Min = (long long)1e19;
    for (int j = 1; j <= k; j++)
      Min = min(Min, f[i - 1][j]), f[i][j] = Min + abs(a[i] - b[j]);
  }
  long long ans = f[n][1];
  for (int i = 2; i <= k; i++) ans = min(ans, f[n][i]);
  cout << ans << endl;
  return 0;
}
