#include <bits/stdc++.h>
using namespace std;
int n;
long long a[3005], b[3005], f[3005][3005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] -= i, b[i] = a[i];
  sort(b + 1, b + n + 1);
  int m = unique(b + 1, b + n + 1) - b - 1;
  f[1][1] = abs(a[1] - b[1]);
  for (int i = 2; i <= m; i++) f[1][i] = min(abs(a[1] - b[i]), f[1][i - 1]);
  for (int i = 2; i <= n; i++) f[i][1] = abs(a[i] - b[1]) + f[i - 1][1];
  for (int i = 2; i <= n; i++)
    for (int j = 2; j <= m; j++)
      f[i][j] = min(f[i][j - 1], f[i - 1][j] + abs(a[i] - b[j]));
  cout << f[n][m];
  return 0;
}
