#include <bits/stdc++.h>
using namespace std;
long long a[int(3e3 + 5)], b[int(3e3 + 5)];
long long f(int i, int j) {
  if (i == 1 && j == 1) return abs(a[1] - b[1]);
  static long long dp[int(3e3 + 5)][int(3e3 + 5)];
  static bool mark[int(3e3 + 5)][int(3e3 + 5)];
  auto& ans = dp[i][j];
  if (mark[i][j]) return ans;
  mark[i][j] = true;
  ;
  if (i == 1)
    ans = min(f(1, j - 1), abs(a[1] - b[j]));
  else if (j == 1)
    ans = f(i - 1, 1) + abs(a[i] - b[1]);
  else
    ans = min(f(i - 1, j) + abs(a[i] - b[j]), f(i, j - 1));
  return ans;
}
int main() {
  int n, k = 0;
  scanf("%d", &(n));
  set<long long> s;
  for (int i = 1, __R = n; i <= __R; i++) {
    scanf("%lld", &(a[i]));
    a[i] -= i;
    s.insert(a[i]);
  }
  for (long long x : s) b[++k] = x;
  cout << f(n, k) << endl;
  return 0;
}
