#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3007;
const int INF = 1e9 + 30009;
int N;
int A[MAXN];
priority_queue<int> pq;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  long long ans = 0;
  int maxx = -INF;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] -= i;
  }
  for (int i = 1; i <= N; i++) {
    pq.push(A[i]);
    if (pq.top() > A[i]) {
      ans += pq.top() - A[i];
      pq.pop();
      pq.push(A[i]);
    }
  }
  cout << ans;
  return 0;
}
