#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 4e5 + 10;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0, iend = n; i < iend; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    cout << a[0];
    return;
  }
  long long ans[n];
  memset(ans, 0, sizeof(ans));
  long long finalAdd = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long sum = a[i];
    sum += a[i + 1];
    long long add = 0;
    if (sum < k) {
      add = k - sum;
      finalAdd += add;
    }
    ans[i] = a[i];
    ans[i + 1] = a[i + 1] + add;
    a[i + 1] = ans[i + 1];
  }
  cout << finalAdd << endl;
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
