#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n + 1];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  int arr2[501];
  int indx = 0, counter = 0;
  arr2[0] = arr[0];
  for (int i = 1; i < n; i++) {
    if (arr[i] + arr[i - 1] < k) {
      int diff = k - (arr[i] + arr[i - 1]);
      counter += diff;
      arr2[++indx] = arr[i] + diff;
      arr[i] += diff;
    } else {
      arr2[++indx] = arr[i];
    }
  }
  cout << counter << endl;
  for (int i = 0; i <= indx; i++) {
    cout << arr2[i] << " ";
  }
  cout << endl;
  return 0;
}
