#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e15;
const long long N = 3005;
long long arr[N];
long long dp[N][N], f[N];
set<long long> st;
signed main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    arr[i] -= i;
    st.insert(arr[i]);
  }
  long long cnt = 0;
  while (st.empty() == false) {
    long long x = *st.begin();
    cnt++;
    f[cnt] = x;
    st.erase(st.begin());
  }
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= cnt; j++) dp[i][j] = oo;
  for (long long i = 1; i <= cnt; i++) dp[0][i] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= cnt; j++) {
      long long mn = oo;
      mn = min(mn, dp[i - 1][j] + abs(arr[i] - f[j]));
      mn = min(mn, dp[i][j - 1]);
      dp[i][j] = mn;
    }
  }
  cout << dp[n][cnt];
}
