#D5250. Sort
Sort
Sort
Problem statement
There is a permutation with sorted. I want to select two different numbers , and replace them repeatedly to make them sorted (in the order of ). Every time you replace the numbers , , you need .
Let be the minimum cost required to sort for the permutation . Find the maximum possible value of .
Constraint
input
Input follows the following format. All given numbers are integers.
output
Output the maximum value on one line.
Example
Input
3 0 1 3 1 0 8 3 8 0
Output
5
inputFormat
input
Input follows the following format. All given numbers are integers.
outputFormat
output
Output the maximum value on one line.
Example
Input
3 0 1 3 1 0 8 3 8 0
Output
5
样例
3
0 1 3
1 0 8
3 8 0
5