#include <bits/stdc++.h>
using namespace std;
long long a[3004], dp[2][3004];
vector<long long> b;
long long inf = 1e15;
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    b.push_back(a[i]);
  }
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  m = b.size();
  dp[0][0] = abs(a[0] - b[0]);
  for (int j = 1; j < m; j++) dp[0][j] = min(dp[0][j - 1], abs(a[0] - b[j]));
  bool now = 0;
  for (int i = 1; i < n; i++) {
    now = !now;
    dp[now][0] = dp[!now][0] + abs(a[i] - b[0]);
    for (int j = 1; j < m; j++)
      dp[now][j] = min(dp[now][j - 1], abs(a[i] - b[j]) + dp[!now][j]);
  }
  cout << dp[now][m - 1] << "\n";
}
