CF58C.Trees

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

On Bertown's main street nn trees are growing, the tree number ii has the height of aia_{i} meters ( 1<=i<=n1<=i<=n ). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a beautiful sequence. This means that the heights of trees on ends (the 11 st one and the nn -th one) should be equal to each other, the heights of the 22 -nd and the (n1)(n-1) -th tree must also be equal to each other, at that the height of the 22 -nd tree should be larger than the height of the first tree by 11 , and so on. In other words, the heights of the trees, standing at equal distance from the edge (of one end of the sequence) must be equal to each other, and with the increasing of the distance from the edge by 11 the tree height must also increase by 11 . For example, the sequences "2 3 4 5 5 4 3 2" and "1 2 3 2 1" are beautiful, and '1 3 3 1" and "1 2 3 1" are not.

Changing the height of a tree is a very expensive operation, using advanced technologies invented by Berland scientists. In one operation you can choose any tree and change its height to any number, either increase or decrease. Note that even after the change the height should remain a positive integer, i. e, it can't be less than or equal to zero. Identify the smallest number of changes of the trees' height needed for the sequence of their heights to become beautiful.

输入格式

The first line contains integer nn ( 1<=n<=1051<=n<=10^{5} ) which is the number of trees. The second line contains integers aia_{i} ( 1<=ai<=1051<=a_{i}<=10^{5} ) which are the heights of the trees.

输出格式

Print a single number which is the minimal number of trees whose heights will have to be changed for the sequence to become beautiful.

输入输出样例

  • 输入#1

    3
    2 2 2
    

    输出#1

    1
    
  • 输入#2

    4
    1 2 2 1
    

    输出#2

    0
    
首页