#include <bits/stdc++.h>
int main() {
  int i, j, n, k, *a, ext, diff;
  scanf("%d", &n);
  scanf("%d", &k);
  a = new int[n];
  for (i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  ext = 0;
  for (i = 1; i < n; i++) {
    if (a[i] + a[i - 1] < k) {
      diff = k - (a[i] + a[i - 1]);
      a[i] += diff;
      ext += diff;
    }
  }
  printf("%d\n", ext);
  for (i = 0; i < n; i++) {
    printf("%d ", a[i]);
  }
  return 0;
}
