#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 5005;
int n, a[maxn];
priority_queue<int> pq;
long long res = 0;
void Read() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] -= i;
}
void Solve2() {
  for (int i = 1; i <= n; i++) {
    if (!pq.empty() && pq.top() > a[i]) {
      res += pq.top() - a[i];
      pq.pop();
      pq.push(a[i]);
    }
    pq.push(a[i]);
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (fopen("seq"
            ".inp",
            "r")) {
    freopen(
        "seq"
        ".inp",
        "r", stdin);
    freopen(
        "seq"
        ".out",
        "w", stdout);
  }
  int test_case = 1;
  while (test_case--) {
    Read();
    Solve2();
  }
  return 0;
}
