#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long MOD = 100000000LL;
const int N = 3000 + 10;
const double eps = 1e-8;
void fre() { freopen("in.txt", "r", stdin); }
void freout() { freopen("out.txt", "w", stdout); }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int a[N], b[N];
long long dp[N][N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    dp[1][i] = abs(a[1] - b[i]);
  }
  for (int i = 2; i <= n; i++) {
    long long minn = 1e18;
    for (int j = 1; j <= n; j++) {
      minn = min(minn, dp[i - 1][j]);
      dp[i][j] = minn + abs(a[i] - b[j]);
    }
  }
  long long ans = 1e18;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
