#include <bits/stdc++.h>
using namespace std;
const int MAX = 3005;
const int MOD = 1000000007;
int a[MAX];
int b[MAX];
long long dp[MAX][MAX];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i + 1]);
    a[i + 1] -= i;
    b[i + 1] = a[i + 1];
  }
  sort(b + 1, b + n + 1);
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      dp[i][j] = 1000000000000000000;
    }
  }
  for (int i = 0; i < MAX; i++) {
    dp[0][i] = 0LL;
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      dp[i][j] = min((long long)abs(a[i] - b[j]) + dp[i - 1][j], dp[i][j - 1]);
    }
  }
  cout << dp[n][n] << endl;
}
