#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 3000 + 24, INF = (1 << 30);
long long n;
long long a[MAX_N], b[MAX_N], dp[5][MAX_N];
int main() {
  cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b, b + n);
  dp[0][0] = a[0] - b[0];
  for (int i = 1; i < n; i++) {
    dp[0][i] = min(dp[0][i - 1], abs(a[0] - b[i]));
  }
  for (int i = 1; i < n; i++) {
    dp[i % 2][0] = dp[(i - 1) % 2][0] + abs(b[0] - a[i]);
    for (int j = 1; j < n; j++) {
      dp[i % 2][j] =
          min(dp[(i - 1) % 2][j] + abs(a[i] - b[j]), dp[i % 2][j - 1]);
    }
  }
  cout << dp[(n - 1) % 2][n - 1] << endl;
}
