#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& num) {
  bool start = false, neg = false;
  char c;
  num = 0;
  while ((c = getchar()) != EOF) {
    if (c == '-')
      start = neg = true;
    else if (c >= '0' && c <= '9') {
      start = true;
      num = num * 10 + c - '0';
    } else if (start)
      break;
  }
  if (neg) num = -num;
}
const int maxn = 3005;
const long long INF = (long long)(1e18);
int a[maxn], tb[maxn];
long long f[maxn][maxn];
int tot;
inline int hs(int x) { return lower_bound(tb + 1, tb + tot + 1, x) - tb; }
inline int iabs(int x) { return x >= 0 ? x : -x; }
int main() {
  int n;
  read(n);
  for (int i = (1); i <= (n); i++) {
    read(a[i]);
    a[i] -= (i - 1);
    tb[++tot] = a[i];
  }
  sort(tb + 1, tb + tot + 1);
  tot = unique(tb + 1, tb + tot + 1) - tb - 1;
  for (int i = (1); i <= (n); i++) a[i] = hs(a[i]);
  for (int i = (1); i <= (n); i++) f[i][0] = INF;
  for (int j = (1); j <= (tot); j++) f[0][tot] = 0;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (tot); j++) {
      f[i][j] = f[i][j - 1];
      f[i][j] = min(f[i][j], f[i - 1][j] + iabs(tb[a[i]] - tb[j]));
    }
  printf("%I64d\n", f[n][tot]);
  return 0;
}
