#include <bits/stdc++.h>
using namespace std;
bool cmp_pair(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first > p2.first) return true;
  if (p1.first < p2.first) return false;
  return p1.second <= p2.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  if (n == 1) {
    cout << 0 << endl;
    cout << a[0] << endl;
  } else {
    for (int i = 0; i < n - 1; i++) {
      int s = a[i] + a[i + 1];
      if (s < k) {
        a[i + 1] += k - s;
        ans += k - s;
      }
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
