#include <bits/stdc++.h>
using namespace std;
long long dp[3100][3100] = {0};
long long a[3100], b[3100];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b, b + n);
  int k = 1;
  for (int i = 1; i < n; ++i) {
    if (b[i] != b[i - 1]) {
      b[k++] = b[i];
    }
  }
  dp[0][0] = abs(a[0] - b[0]);
  for (int i = 1; i < k; ++i) {
    dp[0][i] = min(dp[0][i - 1], abs(a[0] - b[i]));
  }
  for (int i = 1; i < n; ++i) {
    dp[i][0] = dp[i - 1][0] + abs(a[i] - b[0]);
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < k; ++j) {
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));
    }
  }
  cout << dp[n - 1][k - 1] << endl;
  return 0;
}
