#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int a[N], b[N];
long long dp[N][N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1e18;
    for (int j = 1; j <= n; j++) {
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));
    }
  }
  long long ans = 1e18;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, dp[n][i]);
  }
  cout << ans << endl;
}
