//Dedicated to my love,ivaziva
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
// #ifndef ONLINE_JUDGE
// #include "C:\Users\andre\Downloads\cpp-dump-0.7.0\cpp-dump-0.7.0\cpp-dump.hpp"
// #define dbg(...) cpp_dump(__VA_ARGS__)
// #else
// #define dump(...)
// #endif 
using namespace std;
typedef long long ll;
typedef long double ldb; 
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
const int mxN=2e5+10;   
const int mxlogN=30;  
const ldb eps=0.000001;
const int mod=998244353; //998244353 1e9+7
const int iinf=2e9;
const ll inf=2e18;    
int n,XR=0,a[mxN],b[mxN],rig[mxN][mxlogN],ps[mxN]; 
int node=1,traj[mxN*mxlogN][2],mnIdx[mxN*mxlogN],root[mxN]; 
int pull(int x)
{
    int nx=node++;
    traj[nx][0]=traj[x][0];
    traj[nx][1]=traj[x][1];
    mnIdx[nx]=mnIdx[x];
    return nx; 
}
int add(int pv,int x,int idx)
{
    int curr=pull(pv),rut=curr;
    for(int i=mxlogN-1; i>=0; i--)
    { 
        int st=(x>>i)&1;
        if(traj[curr][st]==-1) traj[curr][st]=node++;
        else traj[curr][st]=pull(traj[curr][st]); 
        curr=traj[curr][st];
        mnIdx[curr]=min(mnIdx[curr],idx); 
    }
    return rut;
}
int calc(int r,int idx)
{
    int ret=0,curr=r;
    for(int i=mxlogN-1; i>=0; i--)
    {
        int st=(XR>>i)&1;
        if(traj[curr][st^1]!=-1&&mnIdx[traj[curr][st^1]]<=idx)
        {
            curr=traj[curr][st^1];
            ret^=(1<<i); 
        }
        else if(traj[curr][st]!=-1&&mnIdx[traj[curr][st]]<=idx)
        {
            curr=traj[curr][st];
        }
        else 
        {
            break;
        }
    }
    return ret; 
}
int main()
{ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;        
    for(int i=0; i<mxN*mxlogN; i++) 
    {
        traj[i][0]=-1;
        traj[i][1]=-1;
        mnIdx[i]=n+1; 
    }  
    for(int i=1; i<=n; i++) 
    { 
        cin >> a[i]; 
        ps[i]=(ps[i-1]^a[i]);  
    }  
    root[0]=0; 
    for(int i=n; i>=1; i--) 
    {   
        root[n-i+1]=add(root[n-i],ps[i],i); 
    }        
    for(int i=1; i<=n; i++) 
    {
        cin >> b[i];  
    }
    for(int bt=0; bt<mxlogN; bt++)
    {  
        for(int i=1; i<=n; i++) rig[i][bt]=-1;    
    }   
    for(int bt=0; bt<mxlogN; bt++)
    { 
        int r=1;
        for(int i=1; i<=n; i++)
        {   
            if(r<i) r=i; 
            while(r<n&&((b[r+1]>>bt)&1)) r++; 
            if(((b[i]>>bt)&1)==0) continue;   
            if(r>=i) rig[i][bt]=r; 
        }   
    }   
    for(int bt=0; bt<mxlogN; bt++)
    {   
        for(int i=1; i<=n; i++)
        {   
            if(((b[i]>>bt)&1)&&(rig[i][bt]==-1)) 
            {    
                rig[i][bt]=n;
            }  
        }     
    }    
    ll ans=0; 
    for(int i=1; i<=n; i++)
    { 
        vector<pair<int,int>> vec;
        for(int bt=0; bt<mxlogN; bt++)
        {
            if(rig[i][bt]==-1) continue; 
            vec.push_back(make_pair(rig[i][bt],bt)); 
        }    
        sort(vec.begin(),vec.end());  
        for(auto x:vec)
        {            
            ans=max(ans,1ll*b[i]*calc(root[n-i+1],x.first));  
            b[i]^=(1<<x.second); 
        }
        XR=ps[i];     
    } 
    cout << ans << "\n";
    return 0;    
}