It is Byteman's birthday today. There are
Byteman's parents know the children very well and they know that some of the children will be noisy, if
they sit too close to each other. Therefore the parents are going to reseat the children in a specific order. Such
an order can be described by a permutation
To seat all the children in the given order, the parents must move each child around the table to the left or to the right some number of seats. For each child, they must decide how the child will move — that is, they must choose a direction of movement (left or right) and distance (number of seats). On the given signal, all the children stand up at once, move to the proper places and sit down.
The reseating procedure throws the birthday party into a mess. The mess is equal to the largest distance any child moves. The children can be reseated in many ways. The parents choose one with minimum mess. Help them to find such a way to reseat the children.
Task
Your task is to write a program that:
- reads from the standard input the number of the children and the permutation describing the desired order of the children,
- determines the minimum possible mess,
- writes the result to the standard output.
Input
The first line of standard input contains one integer
Due to the official test data being weak, an additional test case worth 1 mark has been added that was constructed to break solutions that are incorrect but AC on the official test data. Data are provided by
.Output
The first and the only line of standard output should contain one integer: the minimum possible mess.
Sample Input
6
3 4 5 1 2 6
Sample Output
2
The left figure shows the initial arrangement of the children. The middle figure shows the result of the
following reseating: children number
Comments
Since the original data were weak, an additional test case was added, and all submissions were rejudged.
well im guessing this problem is inpossible in python?