#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int a[N];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int r = 0;
  for (int i = 1; i < n; i++) {
    int o = max(k - (a[i] + a[i - 1]), 0);
    a[i] += o;
    r += o;
  }
  cout << r << endl;
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
