#include <iostream>
#include <bits/stdc++.h>
#include <string>
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);

    ll N;
    cin >> N;

    ll A[N];
    ll B[N];
    ll i, j, maxx;
    bool A_jednake = true, B_jednake = true;
    ll maxB = -1;
    for(i=0; i<N; i++)
    {
        cin >> A[i];
        if(A[i] != 1)
        {
            A_jednake = false;
        }
    }
    for(i=0; i<N; i++)
    {
        cin >> B[i];
        if(B[i] != 1)
        {
            B_jednake = false;
        }
        if(B[i] > maxB)
        {
            maxB = B[i];
        }
    }
    if(A_jednake)
    {
        cout << maxB << endl;
    }
    else if(B_jednake)
    {
        ll prefiksne[N+1];
        prefiksne[0] = 0;
        for(i=1; i<=N; i++)
        {
            prefiksne[i] = prefiksne[i-1] ^ A[i-1];
        }
        maxx = 0;
        for(i=0; i<=N; i++)
        {
            for(j=i+1; j<=N; j++)
            {
                if(maxx < (prefiksne[i] ^ prefiksne[j]))
                {
                    maxx = prefiksne[i] ^ prefiksne[j];
                }
            }
        }
        cout << maxx << endl;
    }
    else
    {
        maxx = 0;
        for(i=0; i<N; i++)
        {
            if(A[i] * B[i] > maxx)
            {
                maxx = A[i] * B[i];
            }
        }
        cout << maxx << endl;
    }

}