#include <bits/stdc++.h>
inline void inp(long long int &n) {
  n = 0;
  int ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  n = n * sign;
}
using namespace std;
long long int n;
const int MAXN = (long long int)3e3 + 100;
long long int dp[MAXN][MAXN];
long long int v[MAXN];
long long int w[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] -= (i - 1);
    w[i] = v[i];
  }
  sort(v + 1, v + n + 1);
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      dp[i][j] = dp[i - 1][j] + abs(w[i] - v[j]);
    }
    for (long long int j = 2; j <= n; j += 1) {
      dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << dp[n][n] << endl;
  return 0;
}
