#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int s[1000000],a[1000000],ab[1000000];
bool comp(int a,int b){
return a>b;
}
int biggest(int b,int c){
int sum=0;
sort(ab+1,ab+b,comp);
for(int i=1;i<=c;i++){
sum+=ab[i];
}
return sum;
}
int tired(int i,int k){
int x=0;
int b=0;
for(int j=k;j<=n;j++){
if(k>1){
if(2*(s[j]-s[k-1])+a[j]>x){
x=2*s[j]+a[j];
b=j;
}
}else{
if(2*s[j]+a[j]>x){
x=2*s[j]+a[j];
b=j;}
}
}
if(i==1){
return x;
}else{
if(b<n && b>1){
return max(x+biggest(b,i-1),x+tired(i-1,b+1));
}else if(b==n){
return x+biggest(b,i-1);
}else{
return x+tired(i-1,b+1);
}
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s[i];
}
for(int i=1;i<=n;i++){
cin>>a[i];
ab[i]=a[i];
}
for(int i=1;i<=n;i++){
cout<<tired(i,1)<<endl;
}
}
推销员noip