#include <bits/stdc++.h>
using namespace std;
int k, n, i, j, ar[2002 + 2], br[2002 + 2];
int main() {
  while (scanf("%d%d", &n, &k) == 2) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &ar[i]);
    }
    if (n == 1) {
      printf("0\n%d\n", ar[1]);
      continue;
    }
    int ans = 0;
    for (i = 1; i <= n - 1; i++) {
      int sm = ar[i] + ar[i + 1];
      if (sm >= k) continue;
      int nd = (k - sm);
      ans += nd;
      ar[i + 1] += nd;
    }
    printf("%d\n", ans);
    for (i = 1; i <= n; i++) {
      printf(" %d", ar[i]);
    }
    printf("\n");
  }
  return 0;
}
