#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int N = 3e3 + 10;
long long a[N], b[N];
long long dp[N][N];
long long cost(int x, int y) {
  return (a[x] - b[y] > 0) ? a[x] - b[y] : b[y] - a[x];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] -= i, b[i] = a[i];
  sort(b + 1, b + 1 + n);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = inf;
  for (int i = 1; i <= n; i++) dp[1][i] = cost(1, i);
  for (int i = 2; i <= n; i++) {
    long long m = inf;
    for (int j = 1; j <= n; j++) {
      m = min(m, dp[i - 1][j]);
      dp[i][j] = m + cost(i, j);
    }
  }
  long long ans = inf;
  for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}
