#include <bits/stdc++.h>
using namespace std;
int n;
long long a[3005];
long long dp[3005][3005];
vector<long long> stuff;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < (signed)(n); i++) {
    cin >> a[i];
    a[i] -= i;
    stuff.push_back(a[i]);
  }
  vector<long long>::iterator ree;
  sort(stuff.begin(), stuff.end());
  ree = unique(stuff.begin(), stuff.end());
  stuff.resize(distance(stuff.begin(), ree));
  int sz = stuff.size();
  for (int i = 0; i < (signed)(sz); i++) {
    dp[0][i] = abs(a[0] - stuff[i]);
    if (i != 0) dp[0][i] = min(dp[0][i], dp[0][i - 1]);
  }
  for (int i = (1); i <= (n - 1); i++) {
    for (int j = 0; j < (signed)(sz); j++) {
      dp[i][j] = dp[i - 1][j] + abs(a[i] - stuff[j]);
      if (j != 0) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << dp[n - 1][sz - 1];
  return 0;
}
