#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:250000000")
using namespace std;
class animal {
 public:
  int n, index;
  bool operator<(animal another) { return n < another.n; }
};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pow_mod(long long x, long long a) {
  if (a == 0) return 1;
  if (a == 1) return x;
  long long res = pow_mod(x, a / 2);
  res = (res * res) % 1000000007;
  if (a % 2) res = res * x % 1000000007;
  return res;
}
long long modulo(long long x) {
  return ((x % 1000000007) + 1000000007) % 1000000007;
}
int convert(long long x) {
  int res = 0, pos = 1;
  while (x != 0) {
    if (x % 2) res += pos;
    x /= 10;
    pos *= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n), b(n), c(n, -(long long)2147483000);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] -= i;
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  int k = n;
  int srez = n - 1, uroven = (long long)2147483000;
  while (k > 0) {
    uroven = b[srez];
    int colom = 0, all = 0;
    for (int i = k - 1; i >= 0; --i) {
      if (a[i] >= uroven) colom++;
      all++;
      if (2 * colom >= all) {
        k = i;
        c[k] = uroven;
        colom = 0;
        all = 0;
      }
    }
    srez--;
  }
  long long answer = 0;
  uroven = 0;
  for (int i = 0; i < n; ++i) {
    if (c[i] != -(long long)2147483000) uroven = c[i];
    answer = answer + abs(uroven - a[i]);
  }
  cout << answer << endl;
  return 0;
}
