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