#include <bits/stdc++.h>
using namespace std;
long long a[3009], b[3009];
long long dp[2][3005];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    a[i] = a[i] - i - 1;
    b[i] = a[i];
  }
  sort(b, b + n);
  int now = 1;
  for (int i = 0; i < n; ++i) {
    now ^= 1;
    for (int j = 0; j < n; ++j) {
      if (i == 0 && j == 0)
        dp[0][0] = 1LL * abs(a[0] - b[0]);
      else if (i == 0)
        dp[now][j] = min(abs(a[i] - b[j]), dp[now][j - 1]);
      else if (j == 0)
        dp[now][j] = abs(a[i] - b[j]) + dp[now ^ 1][j];
      else
        dp[now][j] = min(abs(a[i] - b[j]) + dp[now ^ 1][j], dp[now][j - 1]);
    }
  }
  printf("%lld", dp[now][n - 1]);
  return 0;
}
