#include <bits/stdc++.h>
using namespace std;
const int CST = 3001;
void solve() {
  long long a, b;
  cin >> a;
  vector<long long> x(a);
  for (int i = 0; i < a; ++i) {
    cin >> x[i];
    x[i] += CST - i;
  }
  vector<long long> vals(x);
  sort(vals.begin(), vals.end());
  vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
  vector<long long> dp(vals.size());
  for (int i = 0; i < a; ++i) {
    long long mn = 1e18;
    for (int j = 0; j < vals.size(); ++j) {
      mn = min(mn, dp[j] + abs(x[i] - vals[j]));
      dp[j] = mn;
    }
  }
  cout << dp[dp.size() - 1] << endl;
}
int main() {
  cout.setf(ios::fixed);
  cout.precision(9);
  solve();
  return 0;
}
