#include <bits/stdc++.h>
using namespace std;
int a[3010], b[3010];
long long dp[3010][3010];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] -= i;
  }
  memcpy(b, a, sizeof(a));
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    long long tmp = dp[i - 1][1];
    for (int j = 1; j <= n; j++) {
      tmp = min(tmp, dp[i - 1][j]);
      dp[i][j] = abs(a[i] - b[j]) + tmp;
    }
  }
  long long ans = dp[n][1];
  for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}
