#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n), b(n, 0);
  for (auto &in : a) cin >> in;
  int prev = a[0];
  int res = 0;
  for (int i = 1; i < n; ++i) {
    if (prev + b[i - 1] + a[i] < k) {
      b[i] = k - (prev + a[i] + b[i - 1]);
      res += b[i];
    }
    prev = a[i];
  }
  cout << res << endl;
  for (int i = 0; i < n; ++i) cout << a[i] + b[i] << " ";
  cout << endl;
  return 0;
}
