#include <bits/stdc++.h>
using namespace std;
long long dp[3005][3005], n;
int a[3005], b[3005];
long long ans;
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);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= n; j++) dp[i][j] = 1000000000000000LL;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = min(dp[i][j], dp[i - 1][j] + abs(a[i] - b[j]));
      dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  ans = dp[n][1];
  for (int i = 2; i <= n; i++) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
