### Statement ↵
Given n (n is even number and n <= 168) and a permutation of n. Our task is to do the least swap operator so that the value of↵
↵
the permutation is maximum.↵
↵
The value of a permutation is $\sum\limits_{i=2}^{n}{|p_{i} - p_{i - 1}|}$↵
↵
↵
### Input↵
↵
4↵
↵
1 2 3 4↵
↵
### Output ↵
↵
3↵
↵
### Explain↵
↵
1 2 3 4↵
↵
Swap (p[1], p[3]) : 3 2 1 4↵
↵
Swap (p[3], p[4]) : 3 2 4 1↵
↵
Swap (p[2], p[4]) : 3 1 4 2↵
↵
The value of the permutation now is abs(1 — 3) + abs(4 — 1) + abs(2 — 4) =46↵
↵
And we do 3 swap operators so the output is 3.↵
↵
↵
Given n (n is even number and n <= 168) and a permutation of n. Our task is to do the least swap operator so that the value of↵
↵
the permutation is maximum.↵
↵
The value of a permutation is $\sum\limits_{i=2}^{n}{|p_{i} - p_{i - 1}|}$↵
↵
↵
### Input↵
↵
4↵
↵
1 2 3 4↵
↵
### Output ↵
↵
3↵
↵
### Explain↵
↵
1 2 3 4↵
↵
Swap (p[1], p[3]) : 3 2 1 4↵
↵
Swap (p[3], p[4]) : 3 2 4 1↵
↵
Swap (p[2], p[4]) : 3 1 4 2↵
↵
The value of the permutation now is abs(1 — 3) + abs(4 — 1) + abs(2 — 4) =
↵
And we do 3 swap operators so the output is 3.↵
↵
↵