#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int maxof(int x, int y)
{
    if (x > y)
        return x;
    else
        return y;
}

int main()
{
    int n;
    int a[1000], b[1000];
    int ans;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    int a_id[1000], b_id[1000];
    int a_min = a[0];
    int b_min = b[0];
    int counta = 0, countb = 0;

    for (int i = 1; i < n; i++)
    {
        if (a_min > a[i])
            a_min = a[i];

        if (b_min > b[i])
            b_min = b[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] == a_min)
        {
            a_id[counta] = i;
            counta++;
        }

        if (b[i] == b_min)
        {
            b_id[countb] = i;
            countb++;
        }
    }

    sort(a, a + n);
    sort(b, b + n);

    int a_min2 = a[1];
    int b_min2 = b[1];

    int w = 0;

    for (int i = 0; i < counta; i++)
        for (int j = 0; j < countb; j++)
        {
            if (a_id[i] == b_id[j])
                w = 1;
        }

    if (w != 1)
    {
        if (a_min > b_min)
            ans = a_min;
        else
            ans = b_min;
    }
    else
    {
        if (a_min + b_min < a_min2 && a_min + b_min < b_min2)
        {
            ans = a_min + b_min;
        }
        else
        {
            if (maxof(a_min, b_min2) < maxof(a_min2, b_min))
                ans = maxof(a_min, b_min2);
            else
                ans = maxof(a_min2, b_min);
        }
    }

    cout << ans << endl;

    return 0;
}
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;++i)
#define _rep(i,s,t) for(int i=s;i>=t;--i)
#define Rep(i,s,t) for(int i=s;i<t;++i)
#define go(x) for(int e=las[x];e;e=nxt[e])
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define _open(x) freopen(#x".in","w",stdout)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define Rd rand()<<15|rand()
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
using namespace std;
const int N=1e6+11;
int a[N],b[N];
int A,B;
int n;
int main(){
	gi(n);
	rep(i,1,n)
		gi(a[i]);
	rep(i,1,n)
		gi(b[i]);
	long long ans=0;
	rep(i,1,n){
		A=max(A,a[i]);
		B=max(B,b[i]);
		ans=max(ans,1ll*b[i]*A);
		printf("%lld\n",ans);
	}
	return 0;
}
 