#include <bits/stdc++.h>
using namespace std;
const int MAX = 20005;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long dp[2][MAX];
int data[MAX];
int main() {
  memset(dp, 0x3f, sizeof(dp));
  int n;
  cin >> n;
  vector<int> order;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
    data[i] -= i;
    order.push_back(data[i]);
  }
  sort(order.begin(), order.end());
  order.erase(unique(order.begin(), order.end()), order.end());
  for (int i = 0; i < order.size(); i++) dp[0][i] = 0;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    memset(dp[cur ^ 1], 0x3f, sizeof(dp[cur ^ 1]));
    for (int j = 0; j < order.size(); j++) {
      if (j) dp[cur ^ 1][j] = min(dp[cur ^ 1][j - 1], dp[cur ^ 1][j]);
      dp[cur ^ 1][j] =
          min(dp[cur ^ 1][j], dp[cur][j] + abs(order[j] - data[i]));
    }
    cur ^= 1;
  }
  long long ans = INF;
  for (int i = 0; i < order.size(); i++) ans = min(ans, dp[cur][i]);
  cout << ans << endl;
}
