using System;
internal class Program
{
   
    static void Main(string[] args)
    {
        int n=Convert.ToInt32(Console.ReadLine());
        int[] a=new int[n];
        int[] b=new int[n];
        string[] u1 = Console.ReadLine().Split(' ');
        string[] u2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            a[i]= Convert.ToInt32(u1[i]);
            b[i]= Convert.ToInt32(u2[i]);
        }
        int maxa = 0;
        for(int i = 0;i < n-1; i++)
        {
            if ((a[i] ^ a[i + 1]) > maxa)
            {
                maxa = (a[i] ^ a[i + 1]);
            }
        }
        int maxb = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if ((b[i] & b[i + 1]) > maxb)
            {
                maxb = (b[i] & b[i + 1]);
            }
        }
        Console.WriteLine(maxa *maxb);

    }
}