#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  multiset<long long> s;
  long long now = 0;
  for (int i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    a -= i;
    s.insert(a);
    s.insert(a);
    now -= a;
    long long x = (*s.rbegin());
    s.erase(s.find(x));
    now += x;
  }
  cout << now << "\n";
  return 0;
}
