#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a;
  long long answ = 0;
  priority_queue<int> q;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    a -= i;
    q.push(a);
    if (q.top() > a) {
      answ += q.top() - a;
      q.pop();
      q.push(a);
    }
  }
  cout << answ;
  int qwertyui;
  cin >> qwertyui;
  return 0;
}
