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