#include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define yes "YES"
#define no "NO "

using namespace std;

using ll = long long;
const ll inf=1e18;
using ld = long double;


void solve()
{
    ll n,i,bt,at,j,res=0;
    cin >> n;
    vector<ll>a(n),b(n);
    for(auto &x:a)
    {
        cin >> x;
    }
    for(auto &x:b)
    {
        cin >> x;
    }
    for(i=0;i<n;i++)
    {
        bt=b[i];
        at=0;
        for(j=i;j<n;j++)
        {
            bt&=b[j];
            at^=a[j];
            res=max(res,bt*at);
        }
    }
    cout << res << endl;


}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}