#include <bits/stdc++.h>
using namespace std;
const int N = 4e3 + 5;
int a[N];
long long dp[N][N];
long long MIN[N][N];
struct node {
  int pre;
  int v;
  bool operator<(const node& b) const { return v < b.v; }
} p[N];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] -= i;
    for (int i = 1; i <= n; i++) {
      p[i].v = a[i];
    }
    sort(p + 1, p + n + 1);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= n; j++) MIN[i][j] = 1e18;
    for (int i = 1; i <= n; i++) MIN[0][i] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dp[i][j] = MIN[i - 1][j] + abs(a[i] - p[j].v);
        MIN[i][j] = min(MIN[i][j - 1], dp[i][j]);
      }
    }
    long long ans = 1e18;
    for (int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}
