#include <bits/stdc++.h>
using namespace std;
long long int dp[3010][3010];
long long int makeMonotoneIncrease(vector<long long int> container) {
  int n = container.size() - 1;
  vector<long long int> origin = container;
  sort(container.begin(), container.end());
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == 1) {
        dp[i][j] = dp[i - 1][j] + abs(container[j] - origin[i]);
      } else {
        dp[i][j] =
            min(dp[i][j - 1], dp[i - 1][j] + abs(container[j] - origin[i]));
      }
    }
  }
  return dp[n][n];
}
int main() {
  int n;
  scanf("%d", &n);
  vector<long long int> temp;
  temp.push_back(-123987654321);
  for (int i = 1; i <= n; i++) {
    long long int a;
    scanf("%lld", &a);
    a -= i;
    temp.push_back(a);
  }
  printf("%lld", makeMonotoneIncrease(temp));
}
