#include <bits/stdc++.h>
using namespace std;
struct slope_func {
 public:
  long long a, b;
  priority_queue<long long> bp;
  slope_func(long long aa, long long bb, vector<long long> v) {
    a = aa;
    b = bb;
    for (long long g : v) bp.push(g);
  }
  void slope_add(long long aa, long long bb, vector<long long> v) {
    a += aa;
    b += bb;
    for (long long g : v) bp.push(g);
  }
  void slope_min() {
    while (a + bp.size() > 0) bp.pop();
  }
};
long long n, m, i, j, k;
int main() {
  auto cur = slope_func(0, 0, {});
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> m;
    m -= i;
    cur.slope_min();
    cur.slope_add(-1, m, {m, m});
  }
  vector<long long> lis;
  while (cur.bp.size()) {
    lis.push_back(cur.bp.top());
    cur.bp.pop();
  }
  m = cur.a;
  for (i = lis.size() - 1; i >= 0; i--) {
    if (m == 0) break;
    if (i == lis.size() - 1) {
      k = lis[i] * cur.a + cur.b;
    } else {
      k += (lis[i] - lis[i + 1]) * m;
    }
    m++;
  }
  cout << k << endl;
}
