#include <bits/stdc++.h>
template <typename A, typename B>
inline void umin(A &x, B y) {
  if (x > y) x = y;
}
template <typename A, typename B>
inline void umax(A &x, B y) {
  if (x < y) x = y;
}
const int N = 3003;
using namespace std;
int n;
long long a[N], b[N], dp[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", a + i);
    a[i] = b[i] = a[i] - i;
  }
  sort(b, b + n);
  for (int j = 0; j < n; j++) {
    dp[0][j] = abs(a[0] - b[j]);
    if (j) umin(dp[0][j], dp[0][j - 1]);
  }
  for (int i = 1; i < n; i++)
    for (int j = 0; j < n; j++) {
      dp[i][j] = abs(a[i] - b[j]) + dp[i - 1][j];
      if (j) umin(dp[i][j], dp[i][j - 1]);
    }
  printf("%lld", dp[n - 1][n - 1]);
}
