#include using namespace std; int N; int X[201010], Y[201010]; vector> tp; int ans = 1e9, 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]); } sort(tp.begin(), tp.end()); int sum, x, y; for (int i = 0; i < N; i++) { tie(sum, x, y) = tp[i]; if (x + y < ans) { ans = sum; } if (x >= ans) { p[i] = max(ans - 1, 0); } else { p[i] = x; } } cout << ans << endl; cout << 0 << endl; for (int i = 0; i < N; i++) { cout << p[i] << endl; } cout << ans << endl; return 0; }