#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
const long long oo = 1e18;
long long a[maxn], b[maxn], dp[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  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) dp[i][0] = oo;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(b[j] - a[i]));
    }
  }
  cout << dp[n][n] << endl;
  return 0;
}
