#include <bits/stdc++.h>
using namespace std;
long long d[3333][3333], a[3333], b[3333], x;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    a[i] = x - i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  int bn = unique(b + 1, b + 1 + n) - b - 1;
  memset(d, 127, sizeof(d));
  for (int i = 1; i <= bn; i++) d[1][i] = min(d[1][i - 1], abs(a[1] - b[i]));
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= bn; j++)
      d[i][j] = min(d[i][j - 1], d[i - 1][j] + abs(a[i] - b[j]));
  }
  cout << d[n][bn] << endl;
  return 0;
}
