#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  long long int ar[n], br[n];
  for (long long int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  long long int sum = 0;
  for (long long int i = 1; i < n; i++) {
    if (ar[i] + ar[i - 1] < k) {
      sum += k - (ar[i] + ar[i - 1]);
      ar[i] += k - (ar[i] + ar[i - 1]);
    }
  }
  cout << sum << "\n";
  for (long long int i = 0; i < n; i++) {
    cout << ar[i] << " ";
  }
}
