#include <bits/stdc++.h>
using namespace std;
long long fin[3010];
long long a[3010];
long long dp[3010][3010];
set<long long> vis;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", &a[i]);
  int tot = 0;
  for (int i = 1; i <= n; ++i) {
    long long test = a[i] - (long long)i;
    vis.insert(test);
  }
  while (!vis.empty()) {
    fin[tot++] = *vis.begin();
    vis.erase(vis.begin());
  }
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  memset(dp[0], 0, sizeof(dp[0]));
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < tot; ++j) {
      dp[i][j] = dp[i - 1][j] + abs(a[i] - i - fin[j]);
    }
    for (int j = 1; j < tot; ++j) {
      dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  printf("%I64d\n", dp[n][tot - 1]);
  return 0;
}
