#include <bits/stdc++.h>
using namespace std;
int arr[1000000];
int main() {
  int n;
  long long res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] -= i;
  }
  priority_queue<long long> q;
  q.push(arr[0]);
  for (int i = 1; i < n; i++) {
    q.push(arr[i]);
    if (q.top() > arr[i]) {
      res += abs(q.top() - arr[i]);
      q.pop();
      q.push(arr[i]);
    }
  }
  cout << res << endl;
}
