#include <bits/stdc++.h>
using namespace std;
int n, a[3001], b[3001];
long long mn[3001], f[3001][3001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(a + 1, a + n + 1);
  int cnt = unique(a + 1, a + n + 1) - a;
  for (int i = 1; i < cnt; i++) {
    f[1][i] = abs(b[1] - a[i]);
    if (i == 1)
      mn[i] = f[1][i];
    else
      mn[i] = min(f[1][i], mn[i - 1]);
  }
  for (int i = 2; i <= n; i++)
    for (int j = 1; j < cnt; j++) {
      f[i][j] = abs(b[i] - a[j]) + mn[j];
      if (j == 1)
        mn[j] = f[i][j];
      else
        mn[j] = min(f[i][j], mn[j - 1]);
    }
  long long ans = 1e18;
  for (int i = 1; i < cnt; i++) ans = ans < f[n][i] ? ans : f[n][i];
  cout << ans << endl;
  return 0;
}
