#include <bits/stdc++.h>
using namespace std;
int a[3005], b[3005];
long long dp[3005][3005];
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 + n + 1);
  long long ans = 1e18;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == 1)
        dp[i][j] = dp[i][j - 1] + abs(b[i] - a[j]);
      else
        dp[i][j] = min(dp[i - 1][j], dp[i][j - 1] + abs(b[i] - a[j]));
    }
    ans = min(ans, dp[i][n]);
  }
  printf("%lld\n", ans);
}
