#define FULL_OPEN 
#define DEBUG
//#define STAY
#ifdef FULL_OPEN
//include
//-------------------------
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <chrono>
#include <complex>
#include <condition_variable>
#include <deque>
#include <exception>
#include <forward_list>
#include <fstream>
#include <functional>
#include <future>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <mutex>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

//conversion
//-----------------------
inline int toInt(string s) { int v;istringstream sin(s);sin >> v;return v; }
template<class T>inline string toString(T x) { ostringstream sout;sout << x;return sout.str(); }

//math
//-----------------------
template<class T>inline T sqr(T x) { return x * x; }

//using
//-----------------------
using ll = long long;
using ull = unsigned long long;
using ld = long double;

using pii = pair<int, int>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vii = vector<pair<int, int > >;
using vll = vector<ll>;
using vld = vector<ld>;
using vvi = vector<vi>;
using vvii = vector<vii>;
using vvll = vector<vll>;
using mii = map<int, int>;
using si = set<int>;
using sll = set<ll>;

//function

enum priority_code {
	fs,
	sf,
};
template<class T = void, priority_code t = fs>
struct greater_pair {
	constexpr bool operator()(const T& _Left, const T& _Right)const {
		if (t == sf)
			return (_Left.second > _Right.second ||
			(!(_Right.second > _Left.second) && _Left.first > _Right.first));
		else
			return (_Left.first > _Right.first ||
			(!(_Right.first > _Left.first) && _Left.second > _Right.second));
	}
};
template<class T = void, priority_code t = fs>
struct less_pair {
	constexpr bool operator()(const T& _Left, const T& _Right)const {
		if (t == sf)
			return (_Left.second < _Right.second ||
			(!(_Right.second < _Left.second) && _Left.first < _Right.first));
		else
			return (_Left.first < _Right.first ||
			(!(_Right.first < _Left.first) && _Left.second < _Right.second));
	}
};


//container util
//-----------------------
#define all(con)	begin(con),end(con)
#define rall(con)	rbegin(con),rend(con)
#define call(con)	cbegin(con),cend(con)
#define crall(con)	crbegin(con),crend(con)
#define whole(func,con,...) ([&](decltype((con)) whole) { return (func)(all(whole), ## __VA_ARGS__); })(con)
#define rwhole(f,con,...)	([&](decltype((con)) rwhole) { return (func)(rall(rwhole), ##__VA_ARGS__); })(con)
#define cwhole(f,con,...)	([&](decltype((con)) cwhole) { return (func)(call(cwhole), ##__VA_ARGS__); })(con)
#define crwhole(f,con,...)	([&](decltype((con)) crwhole) { return (func)(crall(crwhole), ##__VA_ARGS__); })(con)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define exist(s,e) ((s).find(e)!=(s).end())
#define sort(c) sort(all(c))
#define reverse(con) reverse(all(con))
#define reset(c) int _c=SZ(a);(c).clear();(c).resize(_c)
#define each(i,c) for(auto&& i :c)
#define each_ipt(x) EACH(itr,x)cin>>itr;
#define each_opt(x) EACH(itr,x)cout<<itr<<endl;

// repetition
//----------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define repeat(i,n) FOR(i,0,n)

//clear memory
#define CLR(a) memset((a).0,sizeof(a))

//debug
#ifdef DEBUG
#define dump(x) cerr<<#x<<"="<<(x)<<endl;
#define dump_pair(x) cerr<<#x<<"=["<<(x).first<<", "<<(x).second<<" ]"<<endl;
#define dump_tuple3(x) cerr<<#x<<"=["<<get<0>((x))<<", "<<get<1>((x))<<", "<<get<2>((x))<<" ]"<<endl;
#define debug(x) cerr<<#x<<"="<<(x)<<"(L"<<__LINE__<<")"<<""<<__FILE__<<endl;
template <typename T>
void dump_contents(const T& v, const string& msg)
{
	cerr << "### " << msg << " ###\n";
	for (const auto& x : v) {
		cerr << x << " ";
	}
	cerr << endl;
}
#else
#define dump(x)
#define dump_pair(x)
#define dump_tuple(x)
#define debug(x)
template <typename T>
void dump_contents(const T& v, const string& msg)
{
}

#endif
#ifdef STAY
#define stay cout<<"Push any key and Enter..."; scanf_s("%*s");
#else
#define stay
#endif

//main func
#define Main							\
	int main(){							\
	cin.tie(0);							\
	ios_base::sync_with_stdio(0);		\
	cout << fixed << setprecision(12);	
#define Fin								\
	stay								\
	return 0;							\
}										
#endif

Main
int n;cin >> n;
vi ipt(n);
repeat(i, n) {
	cin >> ipt[i];
	ipt[i] -= (i + 1);
}
sort(ipt);
int middle1 = ipt[ipt.size() / 2 - 1];
int middle2 = ipt[ipt.size() / 2];
ull res1 = 0, res2 = 0;
repeat(i, n) {
	res1 += abs(ipt[i] - middle1);
	res2 += abs(ipt[i] - middle2);
}
cout << min(res1, res2) << endl;
Fin

Measured memory_bytes: 1024