#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100100], b[100100];
long long dp[2][100100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  int now = 0, last = 1;
  for (int i = 1; i <= n; i++) {
    memset(dp[last], 0, sizeof(dp[last]));
    swap(now, last);
    dp[now][1] = dp[last][1] + abs(a[i] - b[1]);
    for (int j = 2; j <= n; j++) {
      dp[now][j] = min(dp[now][j - 1], dp[last][j] + abs(a[i] - b[j]));
    }
  }
  cout << dp[now][n] << endl;
  return 0;
}
