#include <bits/stdc++.h>
using namespace std;
int a[3002], b[3002];
long long dp[3002][3002];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(a + 1, a + 1 + n);
  long long res = 1e18;
  for (int i = 1; i <= n; i++) {
    dp[1][i] = abs(b[1] - a[i]);
  }
  for (int i = 2; i <= n; i++) {
    long long min_ = 1e18;
    for (int j = 1; j <= n; j++) {
      min_ = min(min_, dp[i - 1][j]);
      dp[i][j] = min_ + abs(b[i] - a[j]);
      if ((i == n) && (dp[i][j] <= res)) res = dp[i][j];
    }
  }
  res = min(res, dp[n][1]);
  cout << res << endl;
}
