program MaxProizvodXORAND;

var A, B: array[1..200000] of longint;
    n, i, l, r: longint;
    maxProizvod, sadXOR, sadAND: longint;

begin
readLn(n);
for i := 1 to n do
    read(A[i]);
for i := 1 to n do
    read(B[i]);

maxProizvod := 0;

for l := 1 to n do
    begin
    sadXOR := 0;
    sadAND := B[l];
    for r := l to n do
        begin
        sadXOR := sadXOR xor A[r];
        sadAND := sadAND and B[r];
        if sadXOR * sadAND > maxProizvod then
            maxProizvod := sadXOR * sadAND;
        if sadAND = 0 then
            break;
        end;
    end;

    WriteLn(maxProizvod);
end.