#include <bits/stdc++.h>
using namespace std;
int A[3005], NUM[3005], n;
long long dp[3005][3005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    A[i] -= i;
    NUM[i] = A[i];
  }
  sort(NUM + 1, NUM + 1 + n);
  int t = unique(NUM + 1, NUM + 1 + n) - 1 - NUM;
  memset(dp, 63, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    long long temp = dp[i - 1][0];
    for (int j = 1; j <= t; j++) {
      temp = min(temp, dp[i - 1][j]);
      dp[i][j] = temp + abs(A[i] - NUM[j]);
    }
  }
  long long ans = 0x7f7f7f7f7f7f7f7f;
  for (int i = 1; i <= t; i++) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
