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