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