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