#include <bits/stdc++.h>
int main() {
  int A[500];
  int k, i, j, n, x, l;
  long int count = 0;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  for (j = 0; j < n - 1; j++) {
    if ((A[j] + A[j + 1]) < k) {
      x = k - (A[j] + A[j + 1]);
      A[j + 1] = A[j + 1] + x;
      count = count + x;
    }
  }
  printf("%ld\n", count);
  for (k = 0; k < n; k++) {
    printf("%d", A[k]);
    printf(" ");
  }
}
