M. Meet Me Halfway
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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$$$.

Input

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

Output the minimum possible sum of distances traveled by the players over all possible choices of the hosting building $$$h$$$.

Examples
Input
3 10
0 0 9
Output
1
Input
5 5
3 4 3 3 0
Output
3
Note

In the first sample, if $$$h = 0$$$, $$$a_3$$$ can go in one move to $$$(9 + 1) \bmod 10 = 0$$$.