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