#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long a[maxn], b[maxn];
long long dp[maxn];
int n;
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 + 1 + n);
  memset(dp, (0), sizeof(dp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == 1)
        dp[j] += abs(a[i] - b[j]);
      else {
        dp[j] = min(dp[j - 1], dp[j] + abs(a[i] - b[j]));
      }
    }
  }
  printf("%lld\n", (dp[n]));
  return 0;
}
