#include <bits/stdc++.h>
using namespace std;
vector<long long int> as;
set<long long int> s;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    a -= i;
    as.push_back(a);
    s.insert(a);
  }
  vector<long long int> unique;
  for (long long int ss : s) {
    unique.push_back(ss);
  }
  long long int dp[2][3010];
  long long int low[2][3010];
  for (int i = 0; i < 1; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = 1e15;
    }
  }
  int start = 0;
  for (int i = 0; i < unique.size(); i++) {
    dp[0][i] = abs(unique[i] - as[0]);
  }
  low[0][0] = dp[0][0];
  for (int j = 1; j < unique.size(); j++) {
    low[0][j] = min(low[0][j - 1], dp[0][j]);
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < unique.size(); j++) {
      dp[i % 2][j] = low[(i - 1) % 2][j] + abs(unique[j] - as[i]);
    }
    low[i % 2][0] = dp[i % 2][0];
    for (int j = 1; j < unique.size(); j++) {
      low[i % 2][j] = min(low[i % 2][j - 1], dp[i % 2][j]);
    }
  }
  long long int ans = 1e15;
  for (int i = 0; i < unique.size(); i++) {
    ans = min(dp[(n - 1) % 2][i], ans);
  }
  cout << ans << endl;
}
