#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &x : v)
    in >> x;
  return in;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (const auto &x : v)
    out << x << ' ';
  return out;
}

template <typename T>
vector<T> scanl1(function<T(T, T)> f, const vector<T> &v) {
  vector<T> r(v.size());
  r[0] = v[0];
  for (int i = 1; i < (int)v.size(); i++) {
    r[i] = f(r[i - 1], v[i]);
  }
  return r;
}

template <typename T, typename A = T, typename B = T>
vector<T> zipWith(function<T(A, B)> f, const vector<A> &va,
                  const vector<B> &vb) {
  vector<T> vt(min(va.size(), vb.size()));
  for (int i = 0; i < (int)vt.size(); i++) {
    vt[i] = f(va[i], vb[i]);
  }
  return vt;
}

int main() {
#ifdef LOCAL_EXEC
  freopen("sample.in", "r", stdin);
  freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  cin >> a >> b;

  a = scanl1<ll>([](ll a, ll b) { return max(a, b); }, a);
  a = zipWith<ll, ll, ll>([](ll a, ll b) -> ll { return a * b; }, a, b);
  a = scanl1<ll>([](ll a, ll b) { return max(a, b); }, a);

  cout << a << endl;

  return 0;
}

#include<iostream>
#include<cstdio>
#include<queue>
#define int long long
#define uc getchar()
#define ph putchar
#define R register
#define CN const
#define rint R int
#define cint CN int
#define ps ph(' ')
#define pe ph('\n')
using namespace std;
cint inf=1e9+7;
cint mix=2e5+5;
inline int in();
inline void out(rint y);
int n=in(),a[mix],mx,ans;
#undef int
int main() {
#define int long long
	for(rint i=1;i<=n;++i)a[i]=in();
	for(rint i=1;i<=n;++i){
		mx=max(mx,a[i]);
		out(ans=max(ans,mx*in())),pe;
	}
}
inline int in() {
	rint x=0;
	R bool f=0;
	R char s=uc;
	while((s<'0'||'9'<s)&&s!='-')s=uc;
	if(s=='-')f=1,s=uc;
	while('0'<=s&&s<='9')(x*=10)+=s^48,s=uc;
	return f?-x:x;
}
inline void out(rint x) {
	if(x<0)ph('-'),x=-x;
	rint y=x/10;
	if(y)out(y);
	ph((x-y*10)^48);
}