#include <bits/stdc++.h>
using namespace std;
const int N = 5e6 + 5;
int a[N];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    cout << a[1] << endl;
    return 0;
  }
  int ans = 0, t;
  for (int i = 2; i <= n; i++) {
    if (a[i] + a[i - 1] < k) {
      t = max(k - (a[i] + a[i - 1]), 0);
      a[i] += t;
      ans += t;
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    cout << a[i] << (i == n ? '\n' : ' ');
  }
  return 0;
}
