#include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define REPEAT(i, k, n) for(int(i)=(k);(i)<((k)+(n));++(i)) int k[1000]; int l[1000]; int m[1000]; int main(){ int N; cin >> N; REP(i,N) cin >> k[i]; int minv = 1<<29; for(int i = 1; i < 1000; i += 2){ memcpy(l, k, sizeof(k)); memset(m,0,sizeof(m)); for(int j = 0; j < i; j++){ m[j] = j+1; if(j > i/2) m[j] = i-j; } int c = 0; for(int j = 0; j < max(i,N); j++){ if(l[j] <= m[j]) continue; int n = l[j]-m[j]; l[j] = m[j]; c += n; for(int k = 0; k < N && n; k++){ while(n && l[k] < m[k]){ l[k]++, n--; } } } bool f = true; for(int j = 0; j < i; j++){ if(l[j] != m[j]) {f = false; break; } } if(f) minv = min(minv, c); } cout << minv << endl; return 0; }