#include using namespace std; int N; long long int X[201010], Y[201010]; vector> tp; long long int ans = 1e18, p[201010]; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> X[i]; } for (int i = 0; i < N; i++) { cin >> Y[i]; } for (int i = 0; i < N; i++) { tp.emplace_back(X[i] + Y[i], X[i], Y[i], i); } sort(tp.begin(), tp.end()); long long int sum, x, y, id; for (int i = 0; i < N; i++) { tie(sum, x, y, id) = tp[i]; if (sum < ans) { ans = sum; } if (x >= ans) { p[id] = ans; } else { p[id] = x; } } cout << ans << endl; cout << 0 << endl; for (int i = 0; i < N; i++) { cout << p[i] << endl; } cout << ans << endl; return 0; }