using System;
    internal class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] A = new int[N];
            int[] B = new int[N];

            string[] unos1 = Console.ReadLine().Split(" ");
            string[] unos2 = Console.ReadLine().Split(" ");

            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(unos1[i]);
                B[i] = int.Parse(unos2[i]);
            }

            int max = A[0] ^ A[1];
            int max1 = B[0] & B[1];
            int br = 0;
            int br1 = 0;
            for (int i = 0; i < N; i++)
            {
                if (br == N - 1)
                {
                    break;
                }
                else
                {
                    if ((A[i] ^ A[i + 1]) >= max)
                    {
                        max = A[i] ^ A[i + 1];
                        br++;
                    }
                    else
                    {
                        br++;
                    }
                }
            }
            for (int i = 0; i < N; i++)
            {
                if (br1 == N - 1)
                {
                    break;
                }
                else
                {
                    if ((B[i] & B[i + 1]) >= max1)
                    {
                        max1 = B[i] & B[i + 1];
                        br1++;
                    }
                    else
                    {
                        br1++;
                    }
                }
            }
            int res = max * max1;
            Console.WriteLine(res);
        }
    }