#include <bits/stdc++.h>
using namespace std;
long long int dp[2][3005];
int main() {
  int n;
  cin >> n;
  vector<long long int> A(n), B(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    A[i] -= i;
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  B.resize(unique(B.begin(), B.end()) - B.begin());
  int m = B.size();
  dp[0][0] = abs(A[0] - B[0]);
  for (int i = 1; i < m; ++i) {
    dp[0][i] = min(abs(A[0] - B[i]), dp[0][i - 1]);
  }
  for (int i = 1; i < n; ++i) {
    int curr = i % 2, prev = (i + 1) % 2;
    dp[curr][0] = abs(A[i] - B[0]) + dp[prev][0];
    for (int j = 1; j < m; ++j) {
      dp[curr][j] = min(abs(A[i] - B[j]) + dp[prev][j], dp[curr][j - 1]);
    }
  }
  cout << dp[(n + 1) % 2][m - 1] << "\n";
  return 0;
}
