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