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