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