#arc082b. [arc082_b]Derangement
[arc082_b]Derangement
Problem Statement
You are given a permutation consisting of ,,..,. You can perform the following operation any number of times (possibly zero):
Operation: Swap two adjacent elements in the permutation.
You want to have for all . Find the minimum required number of operations to achieve this.
Constraints
- is a permutation of .
Input
The input is given from Standard Input in the following format:
..
Output
Print the minimum required number of operations
Sample Input 1
5
1 4 3 5 2
Sample Output 1
2
Swap and , then swap and . is now and satisfies the condition. This is the minimum possible number, so the answer is .
Sample Input 2
2
1 2
Sample Output 2
1
Swapping and satisfies the condition.
Sample Input 3
2
2 1
Sample Output 3
0
The condition is already satisfied initially.
Sample Input 4
9
1 2 4 9 5 8 7 3 6
Sample Output 4
3