#include <bits/stdc++.h>
using namespace std;
long long int variables[3001][3001];
long long int cost[3001][3001];
int n;
long long int a[3001];
void inicjuj() {
  for (int i = 0; i < n; ++i) {
    variables[0][i] = a[i] - i;
  }
  sort(variables[0], variables[0] + n);
  for (int i = 0; i < n; ++i) cost[0][i] = abs(variables[0][i] - a[0]);
}
void __built_column(int X) {
  long long int minpref = 1e18;
  for (int j = 0; j < n; ++j) {
    minpref = min(minpref, cost[X - 1][j]);
    variables[X][j] = variables[X - 1][j] + 1;
    cost[X][j] = minpref + (long long int)abs(a[X] - variables[X][j]);
  }
}
long long int oblicz() {
  for (int i = 1; i < n; ++i) {
    __built_column(i);
  }
  long long int wyn = 1e18;
  for (int j = 0; j < n; ++j) {
    wyn = min(wyn, cost[n - 1][j]);
  }
  return wyn;
}
void wczytaj() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) cin >> a[i];
}
int main() {
  wczytaj();
  inicjuj();
  cout << oblicz() << endl;
}
