using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dva_niza
{
    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[] s1=Console.ReadLine().Split(' ');
            string[] s2=Console.ReadLine().Split(' ');

            for(int k=0; k<n; k++)
            {
                a[k] = int.Parse(s1[k]);
                b[k] = int.Parse(s2[k]);
            }

            int A = a[0];
            int B = b[0];

            int temp;
            int t1 = 0;
            int t2 = 0;

            int br = 0;

            int res = 0;//kako to da long pokazuje rte a radi

            int i = 1;
            for (int L = 0; L < n; L++)
            {
                i = 1;
                while (i <= n - L)
                {
                    if (i == 1)
                    {
                        t1 = a[L];
                        t2 = b[L];

                        temp = t1 * t2;
                        if (temp > res) res = temp;
                    }

                    else
                    {
                        A = a[L + i - 1];
                        B = b[L + i - 1];
                        t1 ^= A;
                        t2 &= B;

                        if (t1 * t2 > res)
                            res = t1 * t2;

                    }
                    i++;
                }
                

            }
            

            Console.WriteLine(res);
        }
    }
}