#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const long long INF = 1e16;
int a[N], b[N], n;
long long dp[N][N];
void solve() {
  int i, j;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i] - i;
    a[i] -= i;
  }
  sort(b + 1, b + n + 1);
  int cnt = unique(b + 1, b + 1 + n) - (b + 1);
  for (i = 0; i < n; i++) {
    long long mn = INF;
    for (j = 1; j <= cnt; j++) {
      mn = min(mn, dp[i][j]);
      dp[i + 1][j] = mn + abs((long long)a[i + 1] - b[j]);
    }
  }
  long long ans = INF;
  for (i = 1; i <= cnt; i++) ans = min(ans, dp[n][i]);
  cout << ans << endl;
}
int main() { solve(); }
