#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll ans;
priority_queue<int> pq;
int n, t;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> t;
  pq.push(t);
  for (int i = 1; i < n; i++) {
    cin >> t;
    t -= i;
    pq.push(t);
    if (pq.top() > t) {
      ans += pq.top() - t;
      pq.pop();
      pq.push(t);
    }
  }
  cout << ans << '\n';
}
