#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
ll n,h[N],w[N],ans[N],t;
stack<ll>s;
int main(){
cin>>n;
for(ll i=1;i<=n;i++)cin>>h[i];
for(ll i=1;i<=n;i++)cin>>w[i];
for(ll i=n;i>=1;i--){
t+=w[i];
while(s.size()&&h[s.top()]<=h[i])t-=w[s.top()],s.pop();
ans[i]+=t,s.push(i);
}
t=0;
while(!s.empty())s.pop();
for(ll i=1;i<=n;i++){
t+=w[i];
while(s.size()&&h[s.top()]<=h[i])t-=w[s.top()],s.pop();
ans[i]+=t,s.push(i),ans[i]-=w[i];
cout<<ans[i]<<" ";
}
}