#include <bits/stdc++.h>
using namespace std;
long long int xx[] = {0, 0, 1, -1};
long long int yy[] = {1, -1, 0, 0};
int main() {
  long long int n;
  cin >> n;
  long long int a[n + 1], b[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
  }
  priority_queue<long long int> pq;
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    pq.push(a[i]);
    if (pq.top() > a[i]) {
      long long int to = pq.top();
      pq.pop();
      ans += to - a[i];
      pq.push(a[i]);
    }
  }
  cout << ans << endl;
}
