#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct po{
int s,a;
}f[100010];
const int N=100010;
int n;
int p[N],q[N],sum[N];
bool cmp(po x,po y){
return x.a>y.a;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++) cin>>f[i].s;
for(int i=1;i<=n;i++) cin>>f[i].a;
sort(f+1,f+1+n,cmp);
for(int i = 1;i <= n;i++) sum[i]=sum[i-1] + f[i].a;
for(int i = 1;i <= n;i++) p[i]=max(p[i-1],2f[i].s);
for(int i = n;i >= 1;i--) q[i]=max(q[i+1],2f[i].s+f[i].a);
for(int i = 1;i <= n;i++) cout<<max(sum[i]+p[i],sum[i-1]+q[i])<<endl;
return 0;
}