#include <iostream>
#include <algorithm>
using namespace std;

int main() 
{
    int n;
    cin >> n;
    int* a = new int[n];
    int* b = new int[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) 
    {
        cin >> b[i];
    }
    int maks = 0;
    for (int i = 0; i < n; i++) 
    {
        int xorv = 0;
        int v = b[i];
        for (int j = i; j < n; j++) 
        {
            xorv ^= a[j];
            v &= b[j];
            int t = xorv * v;
            maks = max(maks, t);
        }
    }
    cout << maks << endl;
    delete[] a;
    delete[] b;

    return 0;
}