#include <bits/stdc++.h>

using namespace std;

struct random_class {
	struct xorshift {
		using result_type = unsigned int;
		result_type x=123456789u,y=362436069u,z=521288629u,w;
		static constexpr result_type min() {return 0u;}
		static constexpr result_type max() {return UINT_MAX;}
		xorshift(result_type a) : w(a) {}
		result_type operator()() {
			result_type t;
			t = x ^ (x << 11);
			x = y; y = z; z = w;
			return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		}
	};
	random_device rd;
	xorshift xor128;
	using u64 = uint_fast64_t;
	random_class() : rd(), xor128(rd()) {}
	random_class(unsigned int seed) : rd(), xor128(seed) {}
	u64 make_random(u64 min_v, u64 max_v) { return uniform_int_distribution<u64>(min_v, max_v)(xor128);}
	u64 make_random_max() { return uniform_int_distribution<u64>(numeric_limits<u64>::min(), numeric_limits<u64>::max())(xor128);}
};

random_class R(1143417);

namespace treap_n{
template<class T>
struct Treap {
	using priority_type = uint_fast64_t;
	struct node {
		T val;
		priority_type pri;
		node *lch, *rch;
		int cnt;
		node(T v) : val(v), lch(nil), rch(nil), cnt(1) {
			pri = R.make_random_max();
		}
		node() : val(), pri(numeric_limits<priority_type>::min()), lch(nullptr), rch(nullptr), cnt(0) {}
		static node* const nil;
	};
	using np = node*;
	np top;
	Treap() : top(node::nil) {}
	np update(np n) {
		n->cnt = n->lch->cnt + n->rch->cnt + 1;
		return n;
	}
	np merge(np l, np r) {
		if (l == node::nil || r == node::nil) return l == node::nil ? r : l;
		if (l->pri > r->pri) {
			l->rch = merge(l->rch, r);
			return update(l);
		} else {
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	pair<np, np> split(np t, int k) {
		if (t == node::nil) return make_pair(node::nil, node::nil);
		if (k <= t->lch->cnt) {
			pair<np, np> s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		} else {
			pair<np, np> s = split(t->rch, k - t->lch->cnt - 1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}
	int find_insert_pos_(np new_node, np n) {
		int pos = 0;
		while (n != node::nil) {
			if (new_node->val < n->val) n = n->lch;
			else pos += n->lch->cnt + 1, n = n->rch;
		}
		return pos;
	}
	np insert(np new_node, np n) {
		if (n == node::nil) return new_node;
		if (new_node->pri < n->pri) {
			np& target = new_node->val < n->val ? n->lch : n->rch;
			target = insert(new_node, target);
			return update(n);
		} else {
			auto p = split(n, find_insert_pos_(new_node, n));
			new_node->lch = p.first;
			new_node->rch = p.second;
			return update(new_node);
		}
	}
	void insert(const T&& val) { top = insert(new node(val), top);}
	void insert(const T& val) { insert((T&&)val);}
	np erase(const T& val, np n) {
		assert(n);
		if (val < n->val) {
			n->lch = erase(val, n->lch);
			return update(n);
		} else if (val > n->val) {
			n->rch = erase(val, n->rch);
			return update(n);
		} else {
			np dn = n;
			n = merge(n->lch, n->rch);
			delete dn;
			return n;
		}
	}
	void erase(const T&& val) { top = erase(val, top);}
	void erase(const T& val) { top = erase(val, top);}
	const T& at(int idx) {
		assert(0 <= idx && idx < size());
		np n = top;
		for (int sz = n->lch->cnt + 1; sz != idx + 1; sz = n->lch->cnt + 1) {
			if (sz <= idx) idx -= sz, n = n->rch;
			else n = n->lch;
		}
		return n->val;
	}
	inline const int size() {
		return top->cnt;
	}
	void dfs(np n) {
		if (!n) return;
		cout << "node " << n->val << " ";
		if (n->lch) cout << "left : " << n->lch->val << " ";
		if (n->rch) cout << "right : " << n->rch->val << " ";
		cout << endl;
		dfs(n->lch);
		dfs(n->rch);
	}
	void print() {
		dfs(top);
	}
};
	template<class T>
	typename Treap<T>::node* const Treap<T>::node::nil = new node();
} // treap_n
using namespace treap_n;

int main() {
	Treap<int> T;
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int t; cin >> t;
		t -= i;
		T.insert(t);
		v.push_back(t);
		// T.print();
		// cout << endl;
	}
	int b = T.at(N / 2);
	long long res = 0;
	for (auto x : v) {
		res += abs(x - b);
	}
	cout << res << endl;
}

// int main() {
// 	Treap<int> T;
// 	vector<int> v;
// 	int C = 100;
// 	while (C--) {
// 		v.push_back(R.make_random(0, 10));
// 		T.insert(v.back());
// 		// T.print(); cout << endl;
// 	}
// 	T.print();
// 	// for (auto& x : v) {
// 	// 	T.erase(x-1);
// 	// }
// 	// T.print();
// }

Measured memory_bytes: 10356