#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000001;
const long long LINF = 1000000000000000001LL;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> tab(n);
  for (int i = (0); i <= (n - 1); ++i) cin >> tab[i];
  long long dp[2][n], dpPref[2][n];
  int values[2][n];
  for (int i = (0); i <= (n - 1); ++i) {
    dp[0][i] = dpPref[0][i] = 0;
    values[0][i] = -INF;
  }
  for (int i = (1); i <= (n); ++i) {
    int t = i % 2;
    for (int j = (0); j <= (n - 1); ++j) {
      values[t][j] = tab[j] + i - 1 - j;
    }
    sort(values[t], values[t] + n);
    for (int j = (0); j <= (n - 1); ++j) {
      int value = values[t][j];
      int ind =
          lower_bound(values[1 - t], values[1 - t] + n, value) - values[1 - t];
      dp[t][j] = abs(value - tab[i - 1]) + dpPref[1 - t][ind - 1];
    }
    for (int j = (0); j <= (n - 1); ++j) {
      dpPref[t][j] = min(dp[t][j], j ? dpPref[t][j - 1] : LINF);
    }
  }
  cout << dpPref[n % 2][n - 1];
  return 0;
}
