#include #define rep(i,n) for( int i=0; i> n; vector> d(n,vector(3)); vector res(n); rep(i,n){ cin >> d[i][0]; } rep(i,n){ cin >> d[i][1]; } rep(i,n){ d[i][2] = i; } sort( d.begin(), d.end(), [](const vector& l, const vector& r){ return l[0]+l[1] < r[0]+r[1]; }); auto ml = (*(d.begin()))[0] + (*(d.begin()))[1]; cout << ml << endl; puts("0"); rep(i,n){ cout << min( d[i][0], ml ) << endl; } }