#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int difference;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] + a[i + 1] < k) {
      difference = k - (a[i] + a[i + 1]);
      ans += difference;
      a[i + 1] = a[i + 1] + difference;
    }
  }
  cout << ans;
  cout << endl;
  ;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
