#include <iostream>
using namespace std;

int main()
{
    int n, i=0, l=0, r=1, p, najv=-1, xors, ands;
    cin>>n;
    int a[n], b[n];
    while (i<n) {
        cin>>a[i];
        i++;
    }
    i=0;
    while (i<n) {
        cin>>b[i];
        i++;
    }
    i=0;
    
    while (l<=n) {
        r=l+1;
        while (r<=n) {
            xors=a[l]^a[l+1];
            ands=b[l]&b[l+1];
            i=l+2;
            while (i<=r) {
                xors = xors ^ a[i];
                ands = ands & b[i];
                i++;
            }
            p=xors*ands;
            if (p>najv) 
                najv=p;
            r++;
            
        } 
        l++;
    }
    cout<<najv;
    return 0;
}