#include <bits/stdc++.h>
using namespace std;
long int a[5001], b[5001];
long long ans[5001];
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[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++) {
      ans[j] += abs(a[i] - b[j]);
      if (j > 1) ans[j] = min(ans[j], ans[j - 1]);
    }
  cout << ans[n];
}
