#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
long long a[maxn], b[maxn], c[maxn];
long long dp[maxn][maxn];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  long long num = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    num = dp[i - 1][1];
    for (int j = 1; j <= n; j++) {
      num = min(num, dp[i - 1][j]);
      dp[i][j] = abs(a[i] - b[j]) + num;
    }
  }
  long long ans = dp[n][1];
  for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}
