#include <bits/stdc++.h>
using namespace std;
int a[3005], b[3005];
long long dp[3005][3005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int j = 0; j < n; j++) {
    if (b[j] - a[0] < 0) dp[0][j] = a[0] - b[j];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j)
        dp[i][j] = dp[i][j - 1];
      else {
        dp[i][j] = a[i] - b[0] + dp[i - 1][j];
      }
      dp[i][j] = min(dp[i][j], dp[i - 1][j] + abs(b[j] - a[i]));
    }
  }
  long long ans = 10000000000000;
  for (int i = 0; i < n; i++) ans = min(ans, dp[n - 1][i]);
  cout << ans << endl;
}
