#include <bits/stdc++.h>
using namespace std;
void cin_ar(int n, int ar[]) {
  for (int i = 0; i < n; i++) cin >> ar[i];
}
void cin_v(int n, vector<int> v) {
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    ;
  }
}
bool cmp(int a, int b) { return a > b; }
vector<bool> v(1000006, true);
void print(int n, int ar[]) {
  for (int i = 0; i < n; i++) cout << ar[i];
  cout << endl;
}
void solve() {
  int n, k;
  cin >> n >> k;
  int ar[n];
  cin_ar(n, ar);
  int extra = 0;
  for (int i = 1; i < n; i++) {
    if (ar[i - 1] + ar[i] < k) {
      int temp = k - (ar[i - 1] + ar[i]);
      extra += temp;
      ar[i] += temp;
    }
  }
  cout << extra << endl;
  for (int i = 0; i < n; i++) cout << ar[i] << " ";
}
void solve_2() {
  int t;
  cin >> t;
  while (t--) solve();
}
int main() {
  solve();
  return 0;
}
