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