Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. 

Empirically Polycarp learned that the dog needs at least *k* walks for any two consecutive days in order to feel good. For example, if *k* = 5 and yesterday Polycarp went for a walk with Cormen 2 times, today he has to go for a walk at least 3 times. 

Polycarp analysed all his affairs over the next *n* days and made a sequence of *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>, where *a*<sub class="lower-index">*i*</sub> is the number of times Polycarp will walk with the dog on the *i*-th day while doing all his affairs (for example, he has to go to a shop, throw out the trash, etc.).

Help Polycarp determine the minimum number of walks he needs to do additionaly in the next *n* days so that Cormen will feel good during all the *n* days. You can assume that on the day before the first day and on the day after the *n*-th day Polycarp will go for a walk with Cormen exactly *k* times. 

Write a program that will find the minumum number of additional walks and the appropriate schedule — the sequence of integers *b*<sub class="lower-index">1</sub>, *b*<sub class="lower-index">2</sub>, ..., *b*<sub class="lower-index">*n*</sub> (*b*<sub class="lower-index">*i*</sub> ≥ *a*<sub class="lower-index">*i*</sub>), where *b*<sub class="lower-index">*i*</sub> means the total number of walks with the dog on the *i*-th day.
The first line contains two integers *n* and *k* (1 ≤ *n*, *k* ≤ 500) — the number of days and the minimum number of walks with Cormen for any two consecutive days. 

The second line contains integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 500) — the number of walks with Cormen on the *i*-th day which Polycarp has already planned.
none
3 5
2 0 1
4
2 3 2
3 1
0 0 0
1
0 1 0
4 6
2 4 3 5
0
2 4 3 5
5 1
0 0 0 0 1
2
0 1 0 1 1
10 500
164 44 238 205 373 249 87 30 239 90
903
164 336 238 262 373 249 251 249 251 249
1 1
1
0
1
5 1
0 0 0 0 0
2
0 1 0 1 0
5 1
0 0 0 0 1
2
0 1 0 1 1
5 2
0 0 0 1 0
3
0 2 0 2 0
5 5
1 4 0 0 0
6
1 4 1 4 1
5 10
1 2 1 0 1
16
1 9 1 9 1
5 10
0 1 0 1 0
18
0 10 0 10 0
10 5
0 2 3 0 0 1 0 2 3 1
13
0 5 3 2 3 2 3 2 3 2
10 1
0 0 0 0 0 0 0 0 1 0
4
0 1 0 1 0 1 0 1 1 0
10 436
13 16 45 9 10 17 5 26 10 12
2017
13 423 45 391 45 391 45 391 45 391
10 438
71 160 43 326 128 35 41 247 30 49
1060
71 367 71 367 128 310 128 310 128 310
10 431
121 24 93 59 243 147 1 254 75 168
1036
121 310 121 310 243 188 243 254 177 254
10 10
0 0 0 0 0 0 0 0 0 0
50
0 10 0 10 0 10 0 10 0 10
10 10
0 0 1 0 0 0 1 0 0 0
48
0 10 1 9 1 9 1 9 1 9
10 10
0 0 0 1 0 0 1 0 0 0
48
0 10 0 10 0 10 1 9 1 9
10 10
1 1 0 2 0 1 1 1 2 0
41
1 9 1 9 1 9 1 9 2 8
10 10
1 2 2 0 0 2 0 1 0 0
42
1 9 2 8 2 8 2 8 2 8
10 10
1 0 1 0 0 5 2 0 0 1
40
1 9 1 9 1 9 2 8 2 8
10 10
2 3 5 0 2 0 15 6 5 0
23
2 8 5 5 5 5 15 6 5 5
10 10
16 15 4 10 14 2 18 11 24 5
0
16 15 4 10 14 2 18 11 24 5
100 100
48 19 63 8 18 22 5 5 12 7 9 37 17 22 58 14 53 25 24 16 22 36 4 2 9 63 52 43 22 72 0 9 12 26 50 1 21 9 40 9 5 6 2 24 1 88 50 7 9 1 3 16 0 17 3 32 47 9 32 87 20 3 45 41 16 43 41 31 28 30 2 31 72 16 74 59 20 34 25 18 48 10 34 20 22 16 3 32 8 34 8 4 45 65 48 42 1 45 11 15
2588
48 52 63 37 63 37 63 37 63 37 63 37 63 37 63 37 63 37 63 37 63 37 63 37 63 63 52 48 52 72 28 72 28 72 50 50 50 50 50 50 50 50 50 50 50 88 50 50 50 50 50 50 50 50 50 50 50 50 50 87 20 80 45 55 45 55 45 55 45 55 45 55 72 28 74 59 41 59 41 59 48 52 48 52 48 52 48 52 48 52 48 52 48 65 48 52 48 52 48 52
100 200
28 52 65 37 1 64 13 57 44 12 37 0 9 68 17 5 28 4 2 12 8 47 7 33 1 27 50 59 9 0 4 27 31 31 49 1 35 43 36 12 5 0 49 40 19 12 39 3 41 25 19 15 57 24 3 9 4 31 42 55 11 13 1 8 0 25 34 52 47 59 74 43 36 47 2 3 1 13 56 48 42 24 4 32 12 3 33 12 14 14 84 32 1 3 8 49 9 18 43 43
7390
28 172 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 65 135 74 126 74 126 74 126 74 126 74 126 74 126 74 126 74 126 74 126 74 126 84 116 84 116 84 116 84 116 84 116
100 10
1 2 7 0 2 0 0 0 2 5 3 2 2 1 0 7 1 6 1 1 5 1 2 3 5 0 0 0 0 0 1 0 1 0 2 1 3 0 1 1 0 0 3 1 6 3 2 2 1 3 1 0 9 1 3 2 3 0 5 1 0 5 5 5 2 1 3 0 1 3 5 2 4 4 1 2 3 0 2 1 3 6 4 3 1 0 9 1 0 3 3 6 7 2 5 2 2 6 0 2
288
1 9 7 3 7 3 7 3 7 5 5 5 5 5 5 7 3 7 3 7 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 4 6 4 6 4 6 4 9 1 9 2 8 2 8 2 8 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 4 6 4 6 9 1 9 3 7 6 7 3 7 3 7 6 4 6
100 500
207 27 83 171 129 204 11 55 58 115 43 280 208 169 23 79 36 59 132 28 13 136 246 134 29 135 176 21 155 175 127 288 68 68 41 156 194 31 44 131 30 31 89 46 180 184 12 29 2 58 70 157 329 294 126 55 79 19 125 15 39 30 2 137 36 151 5 246 176 1 158 31 4 99 192 200 124 66 10 195 180 165 8 79 257 68 5 175 43 141 0 106 38 32 0 56 33 221 144 226
14863
207 293 207 293 207 293 207 293 207 293 207 293 208 292 208 292 208 292 208 292 208 292 246 254 246 254 246 254 246 254 246 288 212 288 212 288 212 288 212 288 212 288 212 288 212 288 212 288 212 288 212 288 329 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 206 294 257 243 257 243 257 243 257 243 257 243 257 243 257 243 257 243
100 500
64 140 15 221 24 106 73 30 275 97 296 55 5 30 47 199 130 44 72 170 7 204 359 40 128 117 45 192 344 112 0 11 196 78 73 53 222 93 88 151 99 283 60 71 4 87 226 46 66 74 23 89 77 60 397 181 0 101 358 54 124 155 19 218 9 140 161 130 308 85 103 85 300 128 19 108 225 136 100 54 30 24 129 245 128 88 160 120 51 154 19 129 114 32 256 30 102 207 115 49
13634
64 436 64 436 64 436 73 427 275 225 296 204 296 204 296 204 296 204 296 204 296 204 359 141 359 141 359 192 344 156 344 156 344 156 344 156 344 156 344 156 344 283 217 283 217 283 226 274 226 274 226 274 226 274 397 181 319 181 358 142 358 155 345 218 282 218 282 218 308 192 308 192 308 192 308 192 308 192 308 192 308 192 308 245 255 245 255 245 255 245 255 245 255 245 256 244 256 244 256 244
1 500
500
0
500
2 1
0 0
1
0 1
1 10
1
0
1
1 4
2
0
2
1 10
2
0
2
1 10
0
0
0
1 5
1
0
1
1 2
1
0
1
1 5
2
0
2
1 3
0
0
0
1 3
1
0
1
1 5
0
0
0
1 7
0
0
0
1 7
1
0
1
1 3
2
0
2
1 5
3
0
3
1 4
3
0
3
1 6
1
0
1
1 6
2
0
2
1 500
0
0
0
3 7
2 3 1
3
2 5 2
1 10
5
0
5
5 10
1 2 3 4 5
10
1 9 3 7 5
2 6
1 2
3
1 5
1 10
3
0
3
1 6
3
0
3
1 100
1
0
1
1 7
2
0
2
2 10
1 2
7
1 9
1 9
1
0
1
#author: sushmanth

from sys import stdin
input = stdin.readline

inp = lambda : list(map(int,input().split()))

def answer():

    extra , total = 0 , 0
    for i in range(n - 1):
        extra = max(0 , k - (a[i] + a[i + 1]))
        total += extra
        a[i + 1] += extra


    print(extra)
    print(*a)


for T in range(1):

    n , k = inp()
    a = inp()

    answer()
    


    




        
    
    
