using System;

public class Zadatak5 
{
    public static void Main() 
    {
        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split();
        string[] b = Console.ReadLine().Split();
        int[] A = new int[n];
        int[] B = new int[n];

        for (int i = 0; i < n; i++) 
        {
            A[i] = int.Parse(a[i]);
            B[i] = int.Parse(b[i]);
        }

        int max = 0;

        for (int L = 0; L < n; L++) 
        {
            int s1 = 0;
            int s2 = int.MaxValue;

            for (int R = L; R < n; R++) 
            {
                s1 ^= A[R];
                s2 &= B[R];
                int rez = s1 * s2;
                if (rez > max) max = rez;
            }
        }

        Console.WriteLine(max);
    }
}