#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int maxn = 3e3 + 5;
int n;
ll a[maxn], b[maxn], dp[2][maxn];
int main(int argc, char const *argv[]) {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    dp[i & 1][0] = LLONG_MAX;
    for (int j = 1; j <= n; j++) {
      dp[i & 1][j] = min(dp[~i & 1][j] + abs(b[j] - a[i]), dp[i & 1][j - 1]);
    }
  }
  cout << dp[n & 1][n] << endl;
  return 0;
}
