Palao and his friends live in the same condominium indexed from $$$0$$$ to $$$m-1$$$. The condominium has a circular layout because the architect, Peppy, loves circles. From building $$$i$$$, you can go to building $$$(i+1) \bmod m$$$ or to building $$$(i-1) \bmod m$$$.
They want to host a LAN party to play Counter-Strike in one of the condominium buildings halls, $$$h$$$. Each person will travel to $$$h$$$ from where they live using the shortest path possible along the circle.
Help Palao determine the minimum possible sum of distances traveled by him and his friends over all possible choices of the hosting building $$$h$$$.
The first line of input contains two numbers $$$n, m$$$ $$$(1 \le n, m \le 2\cdot 10^5)$$$, the number of persons that will play at the LAN party and the number of buildings in the condominium respectively.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(0 \le a_i \le m - 1)$$$ where the $$$i$$$-th person lives.
Output the minimum possible sum of distances traveled by the players over all possible choices of the hosting building $$$h$$$.
3 100 0 9
1
5 53 4 3 3 0
3
In the first sample, if $$$h = 0$$$, $$$a_3$$$ can go in one move to $$$(9 + 1) \bmod 10 = 0$$$.