#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[3000][3000];
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  int A[n], B[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    A[i] -= i;
    B[i] = A[i];
  }
  sort(B, B + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = min((i == 0 ? 0 : dp[i - 1][j]) + abs(A[i] - B[j]),
                     j == 0 ? numeric_limits<ll>::max() : dp[i][j - 1]);
    }
  }
  cout << dp[n - 1][n - 1] << endl;
  return 0;
}
