#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
inline int nxt() {
  int wow;
  scanf("%d", &wow);
  return wow;
}
inline long long int lxt() {
  long long int wow;
  scanf("%lld", &wow);
  return wow;
}
inline double dxt() {
  double wow;
  scanf("%lf", &wow);
  return wow;
}
long long int dp[2][5002];
int main() {
  int n = nxt(), p = 0, c = 1;
  long long int a[5002], b[5002];
  for (int i = 1; i <= n; i++) b[i] = a[i] = lxt() - i;
  sort(b + 1, b + n + 1);
  dp[1][0] = (long long int)1e17;
  for (int j = 1; j <= n; j++) dp[c][j] = min(dp[c][j - 1], abs(b[j] - a[1]));
  for (int i = 2; i <= n; i++) {
    swap(c, p);
    dp[c][0] = (long long int)1e17;
    for (int j = 1; j <= n; j++)
      dp[c][j] = min(dp[c][j - 1], abs(b[j] - a[i]) + dp[p][j]);
  }
  cout << dp[c][n] << endl;
  return 0;
}
