#include<bits/stdc++.h>
#define p1 p*2
#define p2 p*2+1
using namespace std;
const long long F=6000000;
struct sl1{
long long l,r,maxx,poi;
}tre[2][F];
struct sl2{
long long x,val,poi;
}len[2][F],a1[F],a2[F];
struct sl3{
long long maxx,poi;
};
long long n,bian,out,doit;
long long v[F],check[F];
bool cmp(sl2 a,sl2 b){
return a.x<b.x;
}
void pushup(long long p,long long ml){
if(tre[ml][p1].maxx>tre[ml][p2].maxx){
tre[ml][p].maxx=tre[ml][p1].maxx;
tre[ml][p].poi=tre[ml][p1].poi;
}
else{
tre[ml][p].maxx=tre[ml][p2].maxx;
tre[ml][p].poi=tre[ml][p2].poi;
}
}
void build(long long p,long long l,long long r,long long ml){
tre[ml][p].l=l;
tre[ml][p].r=r;
if(l==r){
tre[ml][p].maxx=len[ml][l].val;
tre[ml][p].poi=len[ml][l].poi;
return;
}
long long mid=(l+r)/2;
build(p1,l,mid,ml);
build(p2,mid+1,r,ml);
pushup(p,ml);
}
sl3 ask(long long p,long long l,long long r,long long ml){
if(l<=tre[ml][p].l&&tre[ml][p].r<=r){
sl3 am;
am.maxx=tre[ml][p].maxx;
am.poi=tre[ml][p].poi;
return am;
}
sl3 kl={-1,-1},st={-1,-1};
long long mid=(tre[ml][p].l+tre[ml][p].r)/2;
if(l<=mid){
st=ask(p1,l,r,ml);
if(st.maxx>kl.maxx){
kl=st;
}
}
if(r>mid){
st=ask(p2,l,r,ml);
if(st.maxx>kl.maxx){
kl=st;
}
}
return kl;
}
void change(long long p,long long x){
if(tre[1][p].l==tre[1][p].r){
tre[2][p].maxx=tre[1][p].maxx=0;
return;
}
long long mid=(tre[1][p].l+tre[1][p].r)/2;
if(x<=mid){
change(p1,x);
}
else{
change(p2,x);
}
pushup(p,1);
pushup(p,2);
}
int main(){
scanf("%lld",&n);
for(long long i=1;i<=n;i++){
scanf("%lld",&a1[i].x);
a2[i].x=a1[i].x;
a1[i].poi=a2[i].poi=i;
check[i]=a1[i].x;
}
for(long long i=1;i<=n;i++){
scanf("%lld",&a1[i].val);
a2[i].val=a1[i].val;
a1[i].val+=a1[i].x*2;
}
sort(a1+1,a1+1+n,cmp);
sort(a2+1,a2+1+n,cmp);
for(long long i=1;i<=n;i++){
len[1][i].val=a1[i].val;
len[2][i].val=a2[i].val;
len[1][i].x=a1[i].x;
len[2][i].x=a2[i].x;
len[1][i].poi=a1[i].poi;
len[2][i].poi=a2[i].poi;
}
build(1,1,n,1);
build(1,1,n,2);
for(long long i=1;i<=n;i++){
sl3 opt1,opt2;
opt1.poi=opt2.poi=-1;
opt1.maxx=opt2.maxx=-1;
opt1=ask(1,doit,n,1);
opt1.maxx-=bian*2;
if(doit>=1){
opt2=ask(1,1,doit,2);
}
if(opt1.maxx>opt2.maxx){
out=out+opt1.maxx;
bian=check[opt1.poi];
doit=opt1.poi;
change(1,opt1.poi);
}
if(opt2.maxx>=opt1.maxx){
out=out+opt2.maxx;
change(1,opt2.poi);
}
cout<<out<<endl;
}
return 0;
}