#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int maxn5 = 5 * 1000 * 100 + 10;
const int maxn3 = 3 * 1000 + 10;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1LL * 2 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
long long dp[2][maxn3];
int a[maxn3], val[maxn3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    val[i] = a[i];
  }
  sort(val, val + n);
  for (int i = 0; i < n; i++)
    dp[0][i] = min(abs(a[0] - val[i]) + 0LL, i == 0 ? inf : dp[0][i - 1]);
  for (int i = 1; i < n; i++) {
    dp[i % 2][0] = abs(val[0] - a[i]) + dp[(i - 1) % 2][0];
    for (int j = 1; j < n; j++)
      dp[i % 2][j] =
          min(abs(a[i] - val[j]) + dp[(i - 1) % 2][j], dp[i % 2][j - 1]);
  }
  cout << dp[(n - 1) % 2][n - 1] << endl;
  return 0;
}
