#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MOD = 1e9 + 7;
const int N = 1010;
int n, k;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (a[i - 1] + a[i] < k) {
      ans += k - (a[i - 1] + a[i]);
      a[i] += k - (a[i - 1] + a[i]);
    }
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
