#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int null = 10000;
int n;
map<int, int> mp;
void sol() {
  int i, j, x;
  long long int ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    x -= i;
    mp[x]++;
    if (mp.rbegin()->first > x) {
      ans += mp.rbegin()->first - x;
      mp.rbegin()->second--;
      if (mp.rbegin()->second == 0) mp.erase(mp.rbegin()->first);
      mp[x]++;
    }
  }
  printf("%I64d", ans);
}
int main() {
#pragma comment(linker, "/STACK:268435456")
  sol();
  return 0;
}
