#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> vec(n);
  long long zero = 0;
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
    vec[i] -= i;
  }
  map<long long, long long> dp;
  dp[vec[0]] = 0;
  for (long long i = 1; i < n; ++i) {
    long long a = vec[i];
    map<long long, long long>::iterator jt = dp.lower_bound(a);
    long long h;
    if (jt != dp.begin()) {
      map<long long, long long>::iterator ht = jt--;
      if (ht != dp.end()) {
        h = (a - jt->first) * (ht->second);
        h += (ht->first - a) * (jt->second);
        h /= (ht->first - jt->first);
      } else
        h = jt->second;
    } else {
      h = jt->second + (jt->first - a) * i;
    }
    dp[a] = h;
    for (map<long long, long long>::iterator it = dp.begin(); it != dp.end();
         ++it) {
      long long x = it->first;
      if (x <= a)
        dp[x] += a - x;
      else {
        dp[x] = min(dp[x] + x - a, h);
      }
    }
    long long prev = dp.begin()->second;
    for (map<long long, long long>::iterator it = ++dp.begin(); it != dp.end();
         ++it) {
      it->second = min(it->second, prev);
      prev = it->second;
    }
  }
  long long ans = 2000000000000000;
  for (map<long long, long long>::iterator it = dp.begin(); it != dp.end();
       ++it)
    ans = min(ans, (it->second));
  cout << ans;
  return 0;
}
