#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  const long long inf = (1ll << 60);
  int n;
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
  }
  vector<array<long long, 2>> dp(n + 1, {inf, inf});
  dp[0] = {0, -inf};
  for (int i = 1; i <= n; i++) {
    multiset<long long> one, two;
    long long sa = 0, sb = 0;
    int c = 0;
    auto balance = [&]() {
      while ((int)one.size() - (int)two.size() > 1) {
        long long x = (*one.rbegin());
        one.erase(one.find(x));
        sa -= x;
        two.insert(x);
        sb += x;
      }
      while (two.size() > one.size()) {
        long long x = (*two.begin());
        two.erase(two.find(x));
        sb -= x;
        one.insert(x);
        sa += x;
      }
    };
    auto cost = [&]() -> long long {
      long long m = (*one.rbegin());
      return (m * one.size() - sa + sb - m * two.size());
    };
    for (int j = i; j >= 1; j--) {
      c++;
      if (two.empty() || (a[j] <= (*two.begin()))) {
        one.insert(a[j]);
        sa += a[j];
      } else {
        two.insert(a[j]);
        sb += a[j];
      }
      balance();
      long long l, r;
      if (c & 1)
        l = r = (*one.rbegin());
      else {
        l = (*one.rbegin());
        r = (*two.begin());
      }
      if (r >= dp[j - 1][1])
        dp[i] = min(dp[i], {dp[j - 1][0] + cost(), max(l, dp[j - 1][1])});
    }
  }
  cout << dp[n][0] << "\n";
  return 0;
}
