#include <bits/stdc++.h>
using namespace std;
long a[3001];
long long dp[3001];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  dp[0] = abs(a[0] - v[0]);
  for (int j = 1; j < v.size(); j++) {
    dp[j] = min(dp[j - 1], abs(a[0] - v[j]));
  }
  for (int i = 1; i < n; i++) {
    dp[0] = dp[0] + abs(a[i] - v[0]);
    for (int j = 1; j < v.size(); j++) {
      dp[j] = min(dp[j - 1], dp[j] + abs(a[i] - v[j]));
    }
  }
  long long ans = dp[0];
  for (int i = 1; i < v.size(); i++) ans = min(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
