#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int d1[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int d2[8][2] = {{1, 0}, {0, 1},  {0, -1}, {-1, 0},
                {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};
const long long inf = 3000000000000000;
const long long N = 3001;
long long a[N], b[N], dp[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i + 1];
    a[i + 1] -= i + 1;
    b[i + 1] = a[i + 1];
  }
  sort(b + 1, b + n + 1);
  for (int i = 0; i <= n; ++i) {
    dp[1][i] = inf;
    if (i != 0 && a[1] <= b[i]) dp[1][i] = min(dp[1][i], 0LL);
    if (i != 0) dp[1][i] = min(dp[1][i], abs(a[1] - b[i]));
  }
  for (int i = 2; i <= n; ++i) {
    dp[i][0] = inf;
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));
    }
  }
  cout << dp[n][n] << "\n";
  return 0;
}
