#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n, a[N];
priority_queue<int> q;
long long ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] -= i;
  for (int i = 1; i <= n; i++) {
    if (!q.empty() && q.top() > a[i]) {
      ans += q.top() - a[i];
      q.pop();
      q.push(a[i]);
    }
    q.push(a[i]);
  }
  cout << ans << endl;
  return 0;
}
