#include <bits/stdc++.h>
using namespace std;
long long d[3001][3001];
int n;
long long a[3001], b[3001];
long long ab(long long k) { return k < 0 ? -k : k; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) d[i][j] = (1LL << 62);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(a, a + n);
  d[0][0] = ab(a[0] - b[0]);
  for (int i = 1; i < n; i++) {
    d[i][0] = min(d[i - 1][0], ab(a[i] - b[0]));
  }
  for (int i = 1; i < n; i++) {
    d[0][i] = d[0][i - 1] + ab(a[0] - b[i]);
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      d[i][j] = min(d[i][j], min(d[i - 1][j], d[i][j - 1] + ab(a[i] - b[j])));
      d[i][j] = min(d[i][j], d[i - 1][j - 1] + ab(a[i] - b[j]));
    }
  }
  printf("%lld", d[n - 1][n - 1]);
}
