#include <bits/stdc++.h>
using namespace std;
int n, a[3005], b[3005], df[3005];
long long F[3005][3005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = a[i] - i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  int m = 0;
  b[0] = b[1] - 1;
  for (int i = 1; i <= n; ++i) {
    if (b[i] > b[i - 1]) df[++m] = b[i];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= m; ++j) {
      F[i][j] = 1e18;
    }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      F[i][j] = min(F[i][j - 1], F[i - 1][j] + abs(a[i] - df[j]));
    }
  }
  long long rs = 1e18;
  for (int i = 1; i <= m; ++i) rs = min(rs, F[n][i]);
  cout << rs;
  return 0;
}
