#include <iostream>
#include <algorithm>
using namespace std;

const int MAX_N = 200000;
long long A[MAX_N], B[MAX_N];

int main() {
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) 
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) 
    {
        cin >> B[i];
    }
    long long MAX = 0;

    for (int L = 0; L < N; L++) {
        long long XOR = 0;
        long long AND = B[L];
        
        for (int R = L; R < N; R++) {
            XOR ^= A[R]; 
            AND &= B[R]; 
            MAX = max(MAX, XOR * AND);
        }
    }
    cout << MAX << endl;
    return 0;
}