#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
const double FINF = 1e15;
const double EPS = 1e-9;
const double PI = 2.0 * acos(0.0);
long long dp[2][5005];
int a[5005], b[5005];
int n;
inline void asmin(long long& a, long long b) {
  if (a > b) a = b;
}
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 - 1;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  b[0] = b[1];
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j <= n; ++j) dp[i][j] = LINF;
  dp[0][0] = 0;
  for (int i = 0; i <= n; ++i) {
    int ci = i % 2;
    int ni = 1 - ci;
    for (int j = 0; j <= n; ++j) {
      if (i + 1 <= n) {
        asmin(dp[ni][j], dp[ci][j] + abs(a[i + 1] - b[j]));
      }
      if (j + 1 <= n) {
        asmin(dp[ci][j + 1], dp[ci][j]);
      }
    }
    if (i == n) break;
    for (int j = 0; j <= n; ++j) dp[ci][j] = LINF;
  }
  long long ans = LINF;
  for (int i = 1; i <= n; ++i) asmin(ans, dp[n % 2][i]);
  cout << ans << '\n';
}
