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