#include <bits/stdc++.h>
using namespace std;
long long a[3009], b[3009];
long long dp[3005][3005];
int n;
long long f(int i = n - 1, int j = n - 1) {
  if (i == 0 && j == 0) return 1LL * abs(a[i] - b[j]);
  long long& ret = dp[i][j];
  if (ret != -1) return ret;
  if (i == 0) {
    ret = min(abs(a[i] - b[j]), f(i, j - 1));
  } else if (j == 0) {
    ret = abs(a[i] - b[j]) + f(i - 1, j);
  } else {
    ret = min(abs(a[i] - b[j]) + f(i - 1, j), f(i, j - 1));
  }
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    a[i] = a[i] - i - 1;
    b[i] = a[i];
  }
  sort(b, b + n);
  printf("%lld", f());
  return 0;
}
