#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n;
  cin >> n;
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) a[i] -= i;
  std::vector<long long> b = a;
  sort((b).begin(), (b).end());
  vector<std::vector<long long> > d(n, std::vector<long long>(n, 0));
  for (int i = 0; i < n; i++) d[0][i] = abs(a[0] - b[i]);
  for (int i = 1; i < n; i++) {
    std::vector<long long> ch(n);
    ch[0] = d[i - 1][0];
    for (int j = 1; j < n; j++) ch[j] = min(ch[j - 1], d[i - 1][j]);
    for (int j = 0; j < n; j++) {
      d[i][j] = abs(a[i] - b[j]) + ch[j];
    }
  }
  long long ans = d[n - 1][0];
  for (int i = 0; i < n; i++) ans = min(ans, d[n - 1][i]);
  cout << ans;
}
