Start: Feb, 21, 2019 12:00:00
2018-2019 ACM集训队冬季集训第二次考核
End: Feb, 21, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: B
Result: Accepted
Time: 83ms
Memory: 2108kB
Author: 2018212212064
In contest: 1261

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <iostream>
using namespace std;
const int maxn=int(1e5+10);
int la[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",la+i);
	int p=(n+1)/2;
	for(int i=1;i<=p;++i)
		la[i]-=i-1;
	for(int j=0,i=n;i>p;--i,++j)
		la[i]-=j;
	sort(la+1,la+1+n);
	p=la[p];
	long long ans=0;
	for(int i=1;i<=n;++i)
		ans+=abs(la[i]-p);
	printf("%lld\n",ans);
}