#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   ; n   long long n, k; n   cin >> n >> k; n   vector<long long> arr(n); n   for (long long i = 0; i < n; i++) cin >> arr[i]; n   long long c = 0; n   for (long long i = 1; i < n; i++) { n     if (arr[i] + arr[i - 1] < k) { n       c += k - arr[i] - arr[i - 1]; n       arr[i] = k - arr[i - 1]; n     } n   } n   cout << c <<   n ; n   for (auto i : arr) cout << i <<    ; n   ; n   cout <<   n ; n   return 0; n } n