#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);
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1e18;
    for (int j = 1; j <= n; j++) {
      if (i == 1)
        dp[i][j] = min(dp[i][j - 1], (long long)abs(a[i] - b[j]));
      else
        dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));
    }
  }
  long long ans = 1e18;
  for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  printf("%lld\n", ans);
}
