#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
inline long long in() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int32_t main() {
  long long n = in();
  long long ans = 0;
  priority_queue<long long> q;
  long long x = in();
  q.push(x);
  for (long long i = 1; i < n; i++) {
    x = in();
    x -= i;
    q.push(x);
    ans += q.top() - x;
    if (q.top() != x) {
      q.pop();
      q.push(x);
    }
  }
  cout << ans;
}
