#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 i = 0; i < N; i++) {
        int xor_sum = A[i];
        int and_sum = B[i];

        for (int j = i; j < N; j++) {

            if (j > i) {
                xor_sum ^= A[j];
                and_sum &= B[j];
            }


            long long result = (long long)xor_sum * and_sum;


            max_value = max(max_value, result);
        }
    }

    cout << max_value << endl;

    return 0;
}