#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500 + 10;
int n, k, ar[MAXN], ans;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> ar[i];
  if (n > 1)
    for (int i = 1; i < n; i++) {
      if (ar[i] + ar[i - 1] < k) {
        ans += k - ar[i] - ar[i - 1];
        ar[i] += k - ar[i] - ar[i - 1];
      }
    }
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << ar[i] << ' ';
}
