#include <bits/stdc++.h>
using namespace std;
int n;
long long a[5005], b[5005];
long long f[2][5005];
int main() {
  memset(f, 0x3f, sizeof(f));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) f[0][i] = 0;
  int now = 0;
  for (int i = 1; i <= n; i++) {
    now ^= 1;
    for (int j = 1; j <= n; j++) {
      f[now][j] = min(f[now][j - 1], f[now ^ 1][j] + abs(a[i] - b[j]));
    }
  }
  long long ans = (long long)1e18;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, f[now][i]);
  }
  cout << ans << endl;
  return 0;
}
