#include <iostream>
using namespace std;

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

    int a[200000], b[200000];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];


    int pro = 0;
    for (int l = 0; l < n - 1; l++) {
        for (int d = l + 1; d < n; d++) {
            int aj = a[l], baj = b[l];
            for (int i = l+1; i <= d; i++) {
                aj ^= a[i];
                baj = baj & b[i];
            }
            if (aj * baj > pro) pro = aj * baj;
        }
    }
    cout << pro;
    return 0;
}