#include <bits/stdc++.h>
using namespace std;
const int N = 3333;
long long a[N], b[N], dp[N][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];
    for (int j = 0; j <= n; j++) dp[i][j] = 1e18;
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));
  printf("%lld\n", dp[n][n]);
  return 0;
}
