#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e13;
int n;
long long a[3005], b[3005], dp[3005][3005], res = inf;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; ++i) fill(dp[i], dp[i] + n + 1, inf);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + labs(b[j] - a[i]));
  for (int i = 1; i <= n; ++i) res = min(res, dp[n][i]);
  printf("%lld\n", res);
  return 0;
}
