#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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];

    long long max_value = 0;

    for (int L = 0; L < N; L++) {
        int xor_value = 0;
        int and_value = (1 << 30) - 1;
        for (int R = L; R < N; R++) {
            xor_value ^= A[R];
            and_value &= B[R];
            max_value = max(max_value, (long long)xor_value * and_value);
        }
    }

    cout << max_value << endl;

    return 0;
}