# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Help Chokro

By RUDRA_DAS · Limits 1s, 512 MB

Pias and Chokro are good friends. Pias's birthday is coming soon. So, Chokro wants to gift Pias an array on his birthday. Initially, Chokro has an array $A$ of size $n$ which has values $A_{1}, A_{2}, ..., A_{n}$.

Chokro can perform the following operations on this array any number of times (possibly zero):

1. $A_{i} = A_{i} + 1$.
2. $A_{i} = A_{i} - 1$.

Chokro knows that Pias's lucky number is $k$, and he likes an array of equal values. So, to make him more excited Chokro wants to convert the array such that $A_{1} = A_{2} = ... = A_{n}$ and $A_{i} \% k = 0$ for all $i$ $(1 \leq i \leq n)$.

As Chokro's online classes are starting soon he doesn't have much time. So, he thought that it would be better to write a code to know the minimum number of operations required to convert the array so that Pias likes that.

But Chokro is afraid of programming. So, he wants your help. Can you help Chokro?

## Input

First line will contain two integers $n$, $k$ ($1 \leq n, k \leq 10^{6}$) the size of the array and Pias's lucky number respectively.

Next line will contain n space separated integers $A_{1}$, $A_{2}$, ..., $A_{n}$ ($0 \leq A_{i} \leq 10^{6}$).

## Output

Output a single integer the minimum number of operations Chokro needs to convert the array.

## Samples

InputOutput
5 3
1 8 7 6 4

10

InputOutput
6 2
3 5 7 12 9 0

20


### Statistics

62% Solution Ratio

TUNA_2023Earliest, Jul '20

Saima.153883Fastest, 0.1s

OttoTheDinoLightest, 4.1 MB

OttoTheDinoShortest, 203B