#include <bits/stdc++.h>
using namespace std;
int arr[550];
int main() {
  int i, k, n, extra;
  int totalsum = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (i != 0) {
      extra = arr[i - 1] + arr[i];
      if (extra < k) {
        arr[i] = arr[i] + k - (extra);
        totalsum += (k - extra);
      }
    }
  }
  cout << totalsum << endl;
  for (int j = 0; j < n; j++) {
    cout << arr[j] << " ";
  }
  return 0;
}
