#include <bits/stdc++.h>
using namespace std;
void input() {
  freopen("5.in", "r", stdin);
  freopen("5.ans", "w", stdout);
}
void output() {
  fclose(stdin);
  fclose(stdout);
}
int n;
long long num[3010], v[3010], f[3010][3010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", num + i);
    num[i] -= i;
    v[i] = num[i];
  }
  sort(v + 1, v + n + 1);
  long long now;
  for (int i = 1; i <= n; i++) {
    now = (long long)1 << 60;
    for (int j = 1; j <= n; j++) {
      now = min(now, f[i - 1][j]);
      f[i][j] = now + abs(num[i] - v[j]);
    }
  }
  now = (long long)1 << 60;
  for (int i = 1; i <= n; i++) now = min(now, f[n][i]);
  printf("%I64d\n", now);
  return 0;
}
