Oleg the bank client checks share prices every day. There are *n* share prices he is interested in. Today he observed that each second exactly one of these prices decreases by *k* rubles (note that each second exactly one price changes, but at different seconds different prices can change). Prices can become negative. Oleg found this process interesting, and he asked Igor the financial analyst, what is the minimum time needed for all *n* prices to become equal, or it is impossible at all? Igor is busy right now, so he asked you to help Oleg. Can you answer this question?
The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>, 1 ≤ *k* ≤ 10<sup class="upper-index">9</sup>) — the number of share prices, and the amount of rubles some price decreases each second.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) — the initial prices.
Consider the first example. 

Suppose the third price decreases in the first second and become equal 12 rubles, then the first price decreases and becomes equal 9 rubles, and in the third second the third price decreases again and becomes equal 9 rubles. In this case all prices become equal 9 rubles in 3 seconds.

There could be other possibilities, but this minimizes the time needed for all prices to become equal. Thus the answer is 3.

In the second example we can notice that parity of first and second price is different and never changes within described process. Thus prices never can become equal.

In the third example following scenario can take place: firstly, the second price drops, then the third price, and then fourth price. It happens 999999999 times, and, since in one second only one price can drop, the whole process takes 999999999 * 3 = 2999999997 seconds. We can note that this is the minimum possible time.
3 3
12 9 15
3
2 2
10 9
-1
4 1
1 1000000000 1000000000 1000000000
2999999997
1 11
123
0
20 6
38 86 86 50 98 62 32 2 14 62 98 50 2 50 32 38 62 62 8 14
151
20 5
59 54 19 88 55 100 54 3 6 13 99 38 36 71 59 6 64 85 45 54
-1
100 10
340 70 440 330 130 120 340 210 440 110 410 120 180 40 50 230 70 110 310 360 480 70 230 120 230 310 470 60 210 60 210 480 290 250 450 440 150 40 500 230 280 250 30 50 310 50 230 360 420 260 330 80 50 160 70 470 140 180 380 190 250 30 220 410 80 310 280 50 20 430 440 180 310 190 190 330 90 190 320 390 170 460 230 30 80 500 470 370 80 500 400 120 220 150 70 120 70 320 260 260
2157
100 18
489 42 300 366 473 105 220 448 70 488 201 396 168 281 67 235 324 291 313 387 407 223 39 144 224 233 72 318 229 377 62 171 448 119 354 282 147 447 260 384 172 199 67 326 311 431 337 142 281 202 404 468 38 120 90 437 33 420 249 372 367 253 255 411 309 333 103 176 162 120 203 41 352 478 216 498 224 31 261 493 277 99 375 370 394 229 71 488 246 194 233 13 66 111 366 456 277 360 116 354
-1
4 2
1 2 3 4
-1
3 4
3 5 5
-1
3 2
88888884 88888886 88888888
3
2 1
1000000000 1000000000
0
4 2
1000000000 100000000 100000000 100000000
450000000
2 2
1000000000 1000000000
0
3 3
3 2 1
-1
3 4
3 5 3
-1
3 2
1 2 2
-1
4 2
2 3 3 2
-1
3 2
1 2 4
-1
3 2
3 4 4
-1
3 3
4 7 10
3
4 3
2 2 5 1
-1
3 3
1 3 5
-1
2 5
5 9
-1
2 3
5 7
-1
3 137
1000000000 1000000000 1000000000
0
5 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000
0
3 5
1 2 5
-1
3 3
1000000000 1000000000 999999997
2
2 4
5 6
-1
4 1
1000000000 1000000000 1000000000 1000000000
0
2 3
5 8
1
2 6
8 16
-1
5 3
15 14 9 12 18
-1
3 3
1 2 3
-1
3 3
3 4 5
-1
2 5
8 17
-1
2 1
1 2
1
1 1
1000000000
0
3 3
5 3 4
-1
3 6
10 14 12
-1
2 2
3 5
1
3 5
1 3 4
-1
4 3
1 6 6 6
-1
2 3
1 8
-1
3 5
6 11 17
-1
2 2
1 4
-1
2 4
6 8
-1
2 1
2 3
1
4 4
1 5 8 14
-1
3 3
1 5 3
-1
4 3
1 2 2 5
-1
3 2
1 4 6
-1
2 3
6 9
1
3 3
2 3 4
-1
3 2
9 10 10
-1
2 2
9 12
-1
2 2
100000003 100000005
1
2 3
2 4
-1
3 2
2 3 5
-1
3 3
1 3 4
-1
10 2
2 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
4499999991
3 5
2 4 5
-1
2 3
7 10
1
3 10
10 13 17
-1
2 3
1 6
-1
1 7
1000000000
0
2 4
3 7
1
2 3
2 5
1
20 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
0
3 3
7 8 8
-1
4 10
1 11 100 11
-1
n,k = map(int,input().split(' '))
a = list(map(int,input().split(' ')))
x = min(a)
summ = 0
flag = 1
for i in range(0,len(a)):
    if((a[i]-x)%k==1):
        flag = 0
        break
    summ += (a[i]-x)//k
if(flag):
    print(summ)
else:
    print("-1")