#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 22;
const long long mod = 1e9 + 7;
const double esp = 1e-9;
long long dp[3010][3010];
long long a1[3010], a2[3010], mn[3030];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a1[i]);
    a2[i] = a1[i] - i;
  }
  sort(a2 + 1, a2 + 1 + n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = mn[j] + abs(a1[i] - i - a2[j]);
    }
    mn[1] = dp[i][1];
    for (int j = 2; j <= n; j++) {
      mn[j] = min(mn[j - 1], dp[i][j]);
    }
  }
  long long ans = dp[n][1];
  for (int i = 1; i <= n; i++) {
    ans = min(ans, dp[n][i]);
  }
  printf("%lld\n", ans);
}
