#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"
#define pii pair<int,int>

using namespace std;

const int MAXN = 2e5+5;
const int mod7 = 1e9+7;
const long long inf = INT_MAX;
const int lg = 31;
int n;

vector<int> segand(MAXN<<2,inf);
vector<int> segxor(MAXN<<2);
vector<int> a(MAXN);
vector<int> b(MAXN,inf);

void andbuild(int nod, int tl, int tr)
{
    if(tl == tr)
    {
        segand[nod] = b[tl];
        return;
    }
    int mid = tl+tr>>1;
    andbuild(nod<<1, tl, mid);
    andbuild(nod<<1|1, mid+1, tr);
    segand[nod] = segand[nod<<1] & segand[nod<<1|1];
}

void xorbuild(int nod, int tl, int tr)
{
    if(tl == tr)
    {
        segxor[nod] = a[tl];
        return;
    }
    int mid = tl+tr>>1;
    xorbuild(nod<<1, tl, mid);
    xorbuild(nod<<1|1, mid+1, tr);
    segxor[nod] = segxor[nod<<1] ^ segxor[nod<<1|1];
}

int xorquery(int nod, int tl, int tr, int l, int r)
{
    if(tl > r || tr < l)return 0;
    if(tl >= l && tr <=r)return segxor[nod];
    int mid = tl+ tr>>1;
    return xorquery(nod<<1, tl, mid, l, r) ^ xorquery(nod<<1|1, mid+1, tr, l,r);
}

int andquery(int nod, int tl, int tr, int l, int r)
{
    if(tl > r || tr < l)return inf;
    if(tl >= l && tr <=r)return segand[nod];
    int mid = tl+ tr>>1;
    return andquery(nod<<1, tl, mid, l, r) & andquery(nod<<1|1, mid+1, tr, l,r);
}

struct Node
{
    int value;
	Node *arr[2];
};

Node *newNode()
{
	Node *temp = new Node;
	temp->value = 0;
	temp->arr[0] = NULL;
	temp->arr[1] = NULL;
	return temp;
}

void update(Node *root, int trxor)
{
	Node *temp = root;

	bool val;
	for (int i=lg; i>=0; i--){
		val = trxor & (1<<i);

		if (temp->arr[val] == NULL) temp->arr[val] = newNode();
		temp = temp->arr[val];
	}

	temp->value = trxor;
}

int query(Node *root, int trxor)
{
	Node *temp = root;

	bool val;
	for (int i=lg; i>=0; i--){
		val = trxor & (1<<i);

		if (temp->arr[!val] != NULL) temp = temp->arr[!val];
		else if (temp->arr[val] != NULL) temp = temp->arr[val];
	}

	return trxor^(temp->value);
}

int calc()
{
	Node *root = newNode();
	update(root, 0);
	int rez= 0;
	int trxor = 0;

	for (int i=0; i<n; i++){
		trxor = trxor^a[i];
		update(root, trxor);
		rez = max(rez, query(root, trxor));
	}

	return rez;
}

signed main()
{
    ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0);
    int tt=1;
    ///cin >> tt;
    while(tt--)
    {
        cin >> n;
        bool testcase1 = true;
        bool testcase2 = true;
        for(int i=0; i<n; i++)
        {
            cin >> a[i];
            if(a[i] !=1)testcase1 = 0;
        }
         for(int i=0; i<n; i++)
        {
            cin >> b[i];
            if(b[i] !=1)testcase2 = 0;
        }
        xorbuild(1,0,n-1);
        andbuild(1,0,n-1);
        if(n<=2000)
        {
            long long rez = 0;
            for(int i=0; i<n; i++)
            {
                for(int j=i+1; j<n;j++)
                {
                    rez = max(rez,xorquery(1,0,n-1,i,j) * andquery(1,0,n-1,i,j));
                }
            }
            cout << rez << endl;
        }
        else if(testcase1)
        {
            long long rez = 0;
            for(int i=0; i<n; i++)
            {
                rez = max(rez, b[i]);
            }
            cout << rez << endl;
        }
        else if(testcase2)cout <<calc() << endl;


    }
}