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 i=0; i<n; i++)
            {
                a[i] = int.Parse(s1[i]);
                b[i] = int.Parse(s2[i]);
            }

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

            int temp;
            int br = 0;

            int res = 0;

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

                        temp = A * B;
                        if (temp > res) res = temp;
                    }

                    else
                    {
                        A = a[L];
                        B = b[L];
                        A2 = a[L + 1];
                        B2 = b[L + 1];

                        temp = (A ^ A2) * (B & B2);
                        if (temp > res)
                        {
                            res = temp;
                        }
                        br = 2;
                        while (br < i)
                        {
                            A = A2; 
                            B = B2;
                            A2 = a[L + br];
                            B2 = b[L + br];

                            temp = (A ^ A2) * (B & B2);
                            if (temp > res)
                            {
                                res = temp;
                            }

                            br++;
                        }
                        
                    }

                }
            }

            Console.WriteLine(res);
        }
    }
}