#include <bits/stdc++.h>
using namespace std;
int main() {
  long int i = 0;
  int r, n, c;
  long long int s = 0;
  cin >> n >> r;
  int a[n], b[n];
  while (i < n) {
    cin >> a[i];
    b[i] = a[i];
    i++;
  }
  i = 1;
  while (i < n) {
    c = (b[i] + b[i - 1]) < r ? r - (b[i] + b[i - 1]) : 0;
    b[i] += c;
    s += c;
    i++;
  }
  cout << s << endl;
  i = 0;
  while (i < n) cout << b[i++] << " ";
  return 0;
}
