#include <bits/stdc++.h>
using namespace std;
long long a[3333], dp[3333][3333], b[3333], mx[3333][3333];
int main() {
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%I64d", a + i);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (i = 1; i <= n; i++) {
    mx[i][0] = 1000000000000000LL;
    for (j = 1; j <= n; j++) {
      dp[i][j] = mx[i - 1][j] + abs(a[i] - b[j]);
      mx[i][j] = min(mx[i][j - 1], dp[i][j]);
    }
  }
  long long ans = 1000000000000000LL;
  for (i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
