#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int msz = 10000;
const int mod = 1e9 + 7;
const double eps = 1e-8;
long long dp[3333][3333];
int a[3333];
int b[3333];
map<int, int> mp;
int main() {
  int n;
  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);
  int id = -1;
  for (int i = 0; i < n; ++i) {
    if (i == 0 || b[i] != b[i - 1]) {
      id++;
      b[id] = b[i];
      mp[b[i]] = id;
    }
  }
  memset(dp, INF, sizeof(dp));
  for (int i = 0; i <= id; ++i) {
    dp[0][i] = abs(a[0] - b[i]);
    if (i) dp[0][i] = min(dp[0][i], dp[0][i - 1]);
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j <= id; ++j) {
      dp[i][j] = dp[i - 1][j] + abs(a[i] - b[j]);
      if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  printf("%lld\n", dp[n - 1][id]);
  return 0;
}
