#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, t;
priority_queue<int> q;
int main() {
  scanf("%d%d", &n, &t);
  q.push(t);
  long long ans = 0LL;
  for (int(i) = (1); (i) < (n); (i)++) {
    scanf("%d", &t);
    t -= i;
    q.push(t);
    if (q.top() > t) {
      ans += q.top() - t;
      q.pop();
      q.push(t);
    }
  }
  printf("%lld\n", ans);
}
