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