#include <bits/stdc++.h>
using namespace std;
priority_queue<int> q;
long long n, a, r;
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a);
    q.push(a -= i);
    if (a < q.top()) {
      r += q.top() - a;
      q.pop();
      q.push(a);
    }
  }
  printf("%lld\n", r);
}
