#include <bits/stdc++.h>
using namespace std;
int main() {
  int day, min, count = 0;
  cin >> day >> min;
  int arr[day];
  for (int i = 0; i < day; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < (day - 1); i++) {
    if ((arr[i] + arr[i + 1]) < min) {
      count += min - (arr[i] + arr[i + 1]);
      arr[i + 1] = arr[i + 1] + (min - (arr[i] + arr[i + 1]));
    }
  }
  cout << count << endl;
  for (int i = 0; i < day; i++) {
    cout << arr[i] << " ";
  }
}
