#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long max_podniza(int N, const vector<int>& A, const vector<int>& B) {
    long long max_vrednost = 0;

    for (int L = 0; L < N; ++L) {
        int xor_v = 0;
        int and_v = B[L];
        for (int R = L; R < N; ++R) {
            xor_v ^= A[R]; 
            and_v &= B[R];

            long long vrednost = (long long)xor_v * and_v;
            max_vrednost = max(max_vrednost, vrednost); 
        }
    }
    return max_vrednost; 
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    cout << max_podniza(N, A, B) << endl;
    return 0;
}