#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
vector<int> sieve;
void prime_sieve(int n) {
  sieve.reserve(n + 1);
  for (int i = 0, nnnn = (n + 1); i < nnnn; ++i) sieve[i] = i;
  for (int i = 2, nnnn = (n + 1); i < nnnn; ++i) {
    if (sieve[i] == i) {
      for (int j = 2, nnnn = (n / i + 1); j < nnnn; ++j) {
        if (sieve[i * j] == i * j) sieve[i * j] = i;
      }
    }
  }
}
ll norm(ll a, ll P) {
  while (a >= P) a -= P;
  while (a < 0) a += P;
  return a;
}
ll mul_mod(ll a, ll b, ll P) { return a * b % P; }
ll pow_mod(ll a, ll b, ll P) {
  ll curr = a, ans = 1;
  while (b != 0) {
    if (b & 1) {
      ans *= curr;
      ans %= P;
    }
    curr *= curr;
    curr %= P;
    b >>= 1;
  }
  return ans;
}
ll inv_mod(ll a, ll P) { return pow_mod(a, P - 2ll, P); }
ll div_mod(ll a, ll b, ll P) { return a * inv_mod(b, P) % P; }
int msb(ll a) {
  for (int i = 62; i >= 0; i--) {
    if (a & ((ll)1 << i)) return i + 1;
  }
  return 0;
}
vector<ll> fact;
void Fact(int n, ll P) {
  if (fact.size() < 1) fact.push_back(1);
  for (int i = fact.size(), nnnn = (n + 1); i < nnnn; ++i)
    fact.push_back(fact[i - 1] * i % P);
}
vector<ll> fact_inv;
void Fact_inv(int n, ll P) {
  if (fact_inv.size() < 1) fact_inv.push_back(1);
  for (int i = fact_inv.size(), nnnn = (n + 1); i < nnnn; ++i)
    fact_inv.push_back(fact_inv[i - 1] * inv_mod(i, P) % P);
}
ll nCr(int n, int r, ll P) {
  if (r > n) return 0;
  Fact(n, P);
  Fact_inv(n, P);
  return (fact[n] * fact_inv[r] % P) * fact_inv[n - r] % P;
}
ll nCr_inv(int n, int r, ll P) {
  if (r > n) return 0;
  Fact(n, P);
  Fact_inv(n, P);
  return (fact_inv[n] * fact[r] % P) * fact[n - r] % P;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1000000007;
void solve() {
  ll n, ans = 0;
  cin >> n;
  priority_queue<ll> pq;
  for (int i = 0, nnnn = (n); i < nnnn; ++i) {
    ll temp;
    cin >> temp;
    temp -= i;
    pq.push(temp);
    ans += pq.top() - temp;
    pq.pop();
    pq.push(temp);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(16) << fixed;
  solve();
}
