#include <bits/stdc++.h>
using namespace std;
const long long int N = 3000 + 10;
const long long int M = 10000 + 10;
const int MOD = 1e9 + 7;
const long long int INF = 1e18 + 10;
int n, a[N];
long long int dp[N][N], ans = INF;
vector<int> all;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    all.push_back(a[i]);
  }
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = INF;
    }
  }
  for (int i = 1; i <= n; i++) {
    long long int mn = INF;
    for (int j = 0; j < (int)all.size(); j++) {
      mn = min(mn, dp[i - 1][j]);
      dp[i][j] = min(dp[i][j], mn + abs(all[j] - a[i]));
      if (i == n) ans = min(ans, dp[i][j]);
    }
  }
  cout << ans << '\n';
  return 0;
}
