#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
const long long INF = 0x7fffffffffffffff;
long long a[maxn], b[maxn], dp[maxn][maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    long long min1 = INF;
    for (int j = 1; j <= n; j++) {
      min1 = min(min1, dp[i - 1][j]);
      dp[i][j] = min1 + abs(a[i] - b[j]);
    }
  }
  long long ans = INF;
  for (int j = 1; j <= n; j++) {
    ans = min(dp[n][j], ans);
  }
  cout << ans << endl;
  return 0;
}
