#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  priority_queue<int> q;
  q.push(x - 1);
  long long ans = 0;
  for (int i = 2; i <= n; ++i) {
    scanf("%d", &x), x -= i;
    q.push(x);
    if (q.top() > x) {
      q.push(x);
      ans += (long long)q.top() - (long long)x;
      q.pop();
    }
  }
  printf("%I64d", ans);
  return 0;
}
