#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 5;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int arr[n + 5], cntr = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i < n; i++) {
    if (arr[i] + arr[i - 1] < k) {
      cntr += (k - (arr[i] + arr[i - 1]));
      arr[i] += (k - (arr[i] + arr[i - 1]));
    }
  }
  cout << cntr << '\n';
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  return 0;
}
