#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int a[n + 5];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    while (a[i] + a[i + 1] < k) a[i + 1]++, ans++;
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) printf("%d ", a[i]);
  return 0;
}
