#include <bits/stdc++.h>
using namespace std;
int A[3005], B[3005];
long long dp[20][3005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    A[i] -= i;
    B[i - 1] = A[i];
  }
  sort(B, B + n);
  int m = unique(B, B + n) - B;
  for (int i = 0; i < m; i++) dp[1][i] = abs(A[1] - B[i]);
  for (int i = 2; i <= n; i++) {
    long long mi = (1LL << 62);
    int cur = i & 1;
    for (int j = 0; j < m; j++) {
      if (dp[!cur][j] < mi) mi = dp[!cur][j];
      dp[cur][j] = mi + abs(A[i] - B[j]);
    }
  }
  long long mi = (1LL << 62);
  for (int i = 0; i < m; i++)
    if (dp[n & 1][i] < mi) mi = dp[n & 1][i];
  cout << mi << endl;
  return 0;
}
