using System;



internal class Program
{
    static void Main(string[] args)
    {

        string s1 = "";
        int n = Convert.ToInt32(Console.ReadLine());
        int[] a = new int[n + 1];
        int[] b = new int[n + 1];
        string s = Console.ReadLine();
        s = s + ' ';
        int m = 0;
        int h = 0;
        string g = Console.ReadLine();
        g = g + ' ';
        for (int i = 1; i <= n; i++)
        {
            s1 = "";
            while (!(s[m].Equals(' ')))
            {
                s1 = s1 + s[m];
                m++;
            }
            m++;
            a[i] = Convert.ToInt32(s1);
            s1 = "";
            while (!(g[h].Equals(' ')))
            {
                s1 = s1 + g[h];
                h++;
            }
            h++;
            b[i] = Convert.ToInt32(s1);
        }
        int max = 0;
        int a1= 0;
        int b1= 255;
        for (int i = 1;i<=n;i++)
        {
            for (int j = i; j <= n; j++)
            {
                a1 = 0;
                b1 = 255;
                for (int k = i; k <= j;k++)
                {
                    a1 = a1 ^ a[k];
                    b1= b1 & b[k];
                }
                if (a1*b1>max) { max=a1*b1; }
            }
        }
        Console.WriteLine(max);

    }
}