#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
multiset<string> S;
long long n, a[3005];
long long f[3005][3005];
long long F[3005];
void update(int u, long long T) {
  for (int i = u; i < 3005; i += i & -i) {
    F[i] = max(F[i], T);
  }
}
long long get(int u) {
  long long res = (1ll << 60);
  for (int i = u; i >= 0; i--) {
    res = min(res, F[i]);
    if (i == 0) break;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<long long> V;
  cin >> n;
  for (int i = (1); i <= (n); ++i) {
    cin >> a[i];
    a[i] += n - i;
  }
  V.push_back(-1000000005);
  for (int i = (1); i <= (n); ++i) V.push_back(a[i]);
  sort((V).begin(), (V).end());
  f[0][0] = 0;
  for (int i = (1); i <= (n); ++i) {
    long long T = (1ll << 60);
    for (int j = (0); j <= (n); ++j) {
      T = min(T, f[i - 1][j]);
      f[i][j] = T + abs(a[i] - V[j]);
    }
  }
  long long res = (1ll << 60);
  for (int i = (1); i <= (n); ++i) res = min(res, f[n][i]);
  cout << res << endl;
  return 0;
}
