#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    vector<long long> a;
    vector<long long> b;
    for(long long i=0; i<n; i++){
        long long x;
        cin >> x;
        a.push_back(x);
    }
    for(long long i=0; i<n; i++){
        long long x;
        cin >> x;
        b.push_back(x);
    }

    long long maks = a[0]*b[0];
    for(long long l=0; l<n; l++){
        long long levi = a[l];
        long long desni = b[l];
        for(long long r=l; r<n; r++){
            levi = (levi^a[r]);
            desni = desni&b[r];
            if(levi*desni>maks){
                maks = levi*desni;
            }
        }
    }

    cout << maks << "\n";
    return 0;
}