#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 256;
const char nxtl = '\n';
const double eps = (double)1e-9;
template <typename T>
inline bool updmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int n, a[MAXN], b[MAXN];
long long dp[3333][3333], pref[3333][3333];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  stable_sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; ++i) pref[i][0] = (long long)1e14;
  for (int i = 1; i <= n; ++i) {
    dp[1][i] = abs(a[1] - b[i]);
    pref[1][i] = min(dp[1][i], pref[1][i - 1]);
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = pref[i - 1][j] + abs(a[i] - b[j]);
      pref[i][j] = min(pref[i][j - 1], dp[i][j]);
    }
  }
  cout << pref[n][n] << nxtl;
  return 0;
}
