#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const long long INF = 1e18;
long long a[N], b[N], f[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    long long ans = INF;
    for (int j = 1; j <= n; j++) {
      ans = min(ans, f[j]);
      f[j] = ans + abs(a[i] - b[j]);
    }
  }
  long long now = INF;
  for (int i = 1; i <= n; i++) now = min(now, f[i]);
  printf("%lld\n", now);
  return 0;
}
