#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 3005;
int tmp[N], t[N], v[N];
long long dp[N][N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &v[i]);
    t[i] = v[i] - i;
    tmp[i] = t[i];
  }
  sort(tmp, tmp + n);
  int m = unique(tmp, tmp + n) - tmp;
  for (int i = 0; i < m; ++i) dp[0][i] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) dp[i + 1][j] = dp[i][j] + abs(t[i] - tmp[j]);
    for (int j = 1; j < m; ++j)
      dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - 1]);
  }
  printf("%lld\n", dp[n][m - 1]);
  return 0;
}
