#include <bits/stdc++.h>
using namespace std;
const int maxn = (1e5) + 15;
const int mod = (1e9) + 7;
const int inf = (1e9) + 3;
long long int n, k, ans;
string s;
long long int a[maxn];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] + a[i - 1] < k)
      ans += (k - a[i] - a[i - 1]), a[i] += (k - a[i] - a[i - 1]);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
