#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX{1000010};
ll as[MAX];
ll solve(ll N) {
  for (int i = 0; i < N; ++i) as[i] -= (i + 1);
  sort(as, as + N);
  auto b = as[N / 2];
  ll ans = 0;
  for (int i = 0; i < N; ++i) ans += labs(as[i] - b);
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> as[i];
  solve(N);
  return 0;
}
