#include <iostream>

using namespace std;

unsigned A[200000];
unsigned B[200000];

int main()
{
    int n;
    unsigned max = 0;
    cin >> n;

    for (int i = 0; i<n; i++) {
        cin >> A[i];
    }

    for (int i = 0; i<n; i++)
        cin >> B[i];

    for (int i = 0; i<n; i++) {
        unsigned tren_xor = A[i];
        unsigned tren_and = B[i];
        max = tren_xor*tren_and > max ? tren_xor*tren_and : max;

        for (int j = i+1; j<n; j++) {
            tren_xor ^= A[j];
            tren_and &= B[j];
            if (tren_and == 0) break;
            max = tren_xor*tren_and > max ? tren_xor*tren_and : max;
        }
    }
    cout << max;

    return 0;
}