#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int n;
int a[N], b[N];
long long dp[N][N];
long long solve(int idx = 0, int val = 0) {
  if (idx == n) return 0;
  if (val == n) return 1e18;
  long long &ret = dp[idx][val];
  if (ret == -1)
    ret = min(solve(idx + 1, val) + abs(a[idx] - b[val]), solve(idx, val + 1));
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i] -= i;
  }
  sort(b, b + n);
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", solve());
  return 0;
}
