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