#include <bits/stdc++.h>
using namespace std;
int n;
long long a[3002], b[3002], f[3002][3002];
int main() {
  ios_base::sync_with_stdio(false);
  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++) {
    long long kq = 10000000000000000;
    for (int j = 1; j <= n; j++) {
      kq = min(kq, f[i - 1][j]);
      f[i][j] = kq + abs(a[i] - b[j]);
    }
  }
  long long ans = 10000000000000000;
  for (int i = 1; i <= n; i++) ans = min(ans, f[n][i]);
  cout << ans;
  return 0;
}
