#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000;
int a[maxn], b[maxn];
long long dp[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  for (int j = 1; j <= n; ++j) {
    cin >> a[j];
    a[j] -= j;
    b[j] = a[j];
  }
  sort(b + 1, b + n + 1);
  for (int j = 1; j <= n; ++j) {
    for (int k = 1; k <= n; ++k) {
      dp[k] += abs(a[j] - b[k]);
      if (k > 1) dp[k] = min(dp[k], dp[k - 1]);
    }
  }
  cout << dp[n] << endl;
  return 0;
}
