n=int(input()) a=[int(i) for i in input().split()]+[0]*100 s=sum(a) h=1 while (h+1)**2j: p+=a[i]-j else: m+=j-a[i] k=2*h-i-2 if a[k]>j: p+=a[k]-j else: m+=j-a[k] c=h-1 if a[c]>h: p+=a[c]-h else: m+=h-a[c] print(max(p,m))