#include <bits/stdc++.h>
using namespace std;
int nn[1009];
int main() {
  int n, k, x = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> nn[i];
  for (int i = 0; i < n - 1; i++) {
    if (nn[i] + nn[i + 1] < k) {
      x += k - (nn[i] + nn[i + 1]);
      nn[i + 1] += (k - (nn[i] + nn[i + 1]));
    }
  }
  cout << x << endl;
  for (int i = 0; i < n; i++) cout << nn[i] << " ";
  cout << endl;
}
