#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double EPS = 1e-10;
mt19937 rng(7);
int a[600];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int cou = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] + a[i] < k) {
      int s = k - a[i - 1] - a[i];
      cou += s;
      a[i] += s;
    }
  }
  printf("%d\n", cou);
  for (int i = 0; i < n; i++) {
    printf("%d ", a[i]);
  }
}
