#include <bits/stdc++.h>
using namespace std;
const int nax = 3005;
const long long INF = 1e18;
long long n, m, a[nax], vec[nax], dp[nax], ans = INF;
set<int> s;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i;
    s.insert(a[i]);
  }
  for (long long x : s) vec[m++] = x;
  for (int i = 0; i < n; i++) {
    long long pre = INF;
    for (int j = 0; j < m; j++) {
      pre = min(pre, dp[j]);
      dp[j] = pre + abs(a[i] - vec[j]);
    }
  }
  for (int i = 0; i < m; i++) ans = min(ans, dp[i]);
  cout << ans << endl;
}
