#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<int> b;
int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,pomav,br;
unsigned long long urez;
long long rez, xrez,pomrez,npom,npomx;
cin>>n;
a.resize(n);
b.resize(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
rez=0; br=0;
vector<pair<int, long long>> niz;
for(int i=0;i<n;i++) {
unordered_map<int,long long> novi;
xrez=a[i];
pomav=b[i];
novi[pomav]=xrez;
pomrez=(long long)pomav*xrez;
rez=max(rez,pomrez);
//urez=(unsigned long long) rez;
//cout <<urez<< endl;
//br++;
//cout<<"Par broj: "<<br<<endl;
for(auto &x:niz)
{
npom=x.first&b[i];
//npom=x.first and b[i];
//cout<<npom;
npomx=x.second^a[i];
//if(novi[npom]<npomx)
 //    novi[npom]=npomx;
if(novi.find(npom)==novi.end() or novi[npom]<npomx)
     novi[npom]=npomx;
//pomrez=npom*npomx;
//pomrez=(unsigned long long)npom*npomx;
pomrez=(long long)npom*npomx;
//cout <<pomrez<< endl;
rez=max(rez,pomrez);
//urez=(unsigned long long) rez;
//cout <<urez<< endl;
}
niz.clear();
    for(auto &x : novi)
   //cout<<x.first<<" "<<x.second<<endl;
    niz.emplace_back(x.first,x.second);
}
//urez=(unsigned long long) rez;
//cout <<urez<< endl;
cout <<rez<< endl;
return 0;
}