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