 /*
    Stay motivated and keep working hard
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define int long long 
#define pb push_back
#define cntbit __builtin_popcount
#define fr first
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--) 
#define md 998244353
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
#define in insert
#define endl "\n"
#define ub  upper_bound
#define lb  lower_bound
#define gcd __gcd
#define setval(a,b) memset(a,b,sizeof(a))
#define lwr lower_bound
#define pii pair<int,int>
#define upr upper_bound
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//CANDIDATE MASTER TOH BNKE RHUNGA
//dsu is pel concept
//KMP is pel concept 
int k,n,t,i,j=0,m;
const int N=1e6+5;
int md2;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
 
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
 
inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}
 
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += md;
  return u;
}
void extgcd(int a,int b, int& x,int& y)
{
    if(b != 0){
        extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    vi a(n),b(n),c(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>b[i];
    int mx[n];
    mx[0]=a[0];
    for(int i=1;i<n;i++)
    mx[i]=max(mx[i-1],a[i]);
    c[0]=a[0]*b[0];
	for(int i=1;i<n;i++)
    c[i]=max(c[i-1],mx[i]*b[i]);
    for(int i=0;i<n;i++)
    cout<<c[i]<<endl;
    
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,e,j;
 //e=1;;
 //while(e--)
 {
	  
	 cin>>n;
	 long a[n],b[n],c[n],max,d;
	 for(i=0;i<n;i++)
	 cin>>a[i];
	 for(i=0;i<n;i++)
	 cin>>b[i];
	 c[0]=0;
	  max=a[0];
	 for(i=1;i<n;i++)
	 {
		 if(a[i]>max)
		 {
			 max=a[i];
			 c[i]=i;
		 }
		 else
		 c[i]=c[i-1];
	 }
	// for(i=0;i<n;i++)
	// cout<<c[i]<<" ";
	  long long dp[n];
	 dp[0]=a[0]*b[0];
	 for(i=1;i<n;i++)
	 {
		 dp[i]=dp[i-1];
		 long long t=a[c[i]]*b[i];
	     if(dp[i]<t)
		 dp[i]=t;
		 
	 }
	 for(i=0;i<n;i++)
	 cout<<dp[i]<<"\n";
 }
}