#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void debug(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const int N = 6030;
const long long INF = (long long)1e18;
long long a[N], b[N];
long long dp[2][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    a[i] -= i;
  }
  for (int i = 0; i < (n); ++i) b[i] = a[i];
  sort(b, b + n);
  for (int i = 0; i < (n); ++i) dp[0][i] = abs(a[0] - b[i]);
  for (int i = (1); i < (n); ++i) {
    int par = i & 1;
    long long prevMin = dp[par ^ 1][0];
    for (int j = 0; j < (n); ++j) {
      prevMin = min(prevMin, dp[par ^ 1][j]);
      dp[par][j] = prevMin + abs(a[i] - b[j]);
    }
  }
  long long ans = INF;
  for (int i = 0; i < (n); ++i) ans = min(ans, dp[(n - 1) % 2][i]);
  cout << ans << endl;
  return 0;
  return 0;
}
