#include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) struct io_setup { io_setup() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; namespace cho { template struct sparse_table { static_assert(std::is_convertible_v>, "op must work as S(S, S)"); std::vector> st; int n; sparse_table() {}; sparse_table(const std::vector& dat) { n = dat.size(); int lg = 1; while ((1 << lg) < n) lg++; st.resize(lg); st[0] = dat; for (int i = 0; i < lg - 1; i++) { int m = st[i].size() - (1 << i); st[i + 1].resize(m); for (int j = 0; j < m; j++) { st[i + 1][j] = op(st[i][j], st[i][j + (1 << i)]); } } } S prod(int l, int r) const { assert(0 <= l && l < r && r <= n); if (l + 1 == r) return st[0][l]; int k = 31 - std::countl_zero((unsigned)(r - l - 1)); return op(st[k][l], st[k][r - (1 << k)]); } }; template S wrapper_max(const S& a, const S& b) { return std::max(a, b); } template using max_sparse_table = sparse_table>; template max_sparse_table get_max_sparse_table(std::vector& v) { return max_sparse_table(v); } template S wrapper_min(const S& a, const S& b) { return std::min(a, b); } template using min_sparse_table = sparse_table>; template min_sparse_table get_min_sparse_table(std::vector& v) { return min_sparse_table(v); } } // namespace cho vector greedy(vector a, vector b) { int n = a.size(); assert((int)b.size() == n); auto ta = cho::get_min_sparse_table(a); auto tb = cho::get_min_sparse_table(b); vector res(n); rep(k, 0, n) { rep(i, 0, k + 1) { int j = k - i; res[k] += min(ta.prod(i, k + 1), tb.prod(j, k + 1)); } } return res; } int main() { int n; cin >> n; vector a(n), b(n); rep(i, 0, n) cin >> a[i]; rep(i, 0, n) cin >> b[i]; auto c = greedy(a, b); rep(i, 0, n) cout << c[i] << ' '; cout << '\n'; }