#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(1250000);

template<class T>
struct Treap {
	struct node {
		T val;
		uint_fast64_t pri;
		node *lch, *rch;
		int cnt;
		node(T v) : val(v), lch(nullptr), rch(nullptr), cnt(1) {
			pri = R.make_random_max();
		}
	};
	node* top;
	Treap(node* t = nullptr) : top(t) {}
	node* update(node* n) {
		n->cnt = count(n->lch) + count(n->rch) + 1;
		return n;
	}
	inline int count(node* n) {
		return !n ? 0 : n->cnt;
	}
	node* merge(node* l, node* r) {
		if (!l || !r) return !l ? 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<node*, node*> split(node* t, int k) {
		if (!t) return make_pair(nullptr, nullptr);
		if (k <= count(t->lch)) {
			pair<node*, node*> s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		} else {
			pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}
	int find_insert_pos_(node* new_node, node* n) {
		int pos = 0;
		while (n) {
			if (new_node->val < n->val) n = n->lch;
			else pos += count(n->lch) + 1, n = n->rch;
		}
		return pos;
	}
	node* insert(node* new_node, node* n) {
		if (!n) return new_node;
		if (new_node->pri < n->pri) {
			if (new_node->val < n->val) {
				n->lch = insert(new_node, n->lch);
				return update(n);
			} else {
				n->rch = insert(new_node, n->rch);
				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);}
	const T& at(int idx) {
		assert(0 <= idx && idx < size());
		node* n = top;
		for (int sz = count(n->lch) + 1; sz != idx + 1; sz = count(n->lch) + 1) {
			if (sz <= idx) idx -= sz, n = n->rch;
			else n = n->lch;
		}
		return n->val;
	}
	inline const int size() {
		return count(top);
	}
	void dfs(node* 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);
	}
};

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;
	// Treap<int> T;
	// for (int i = 0; i < 3; i++) {
	// 	T.insert(i);
	// 	T.print();
	// 	cout << endl;
	// }
}

Measured memory_bytes: 10356