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