#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e17;
const int N = 3010;
const int oo = 1e9;
int n;
long long a[N], b[N];
long long f[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b, b + n);
  f[0][0] = abs(a[0] - b[0]);
  for (int i = 1; i < n; ++i) f[0][i] = min(f[0][i - 1], abs(a[0] - b[i]));
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      f[i][j] = min(j != 0 ? f[i][j - 1] : MAX, f[i - 1][j] + abs(a[i] - b[j]));
    }
  cout << f[n - 1][n - 1];
  return 0;
}
