using System;

namespace ConsoleApp6
{
    internal class Program
    {
        static string bin(string s)
        {
            string b = "";
            int x = int.Parse(s);
            if (x == 0)
            {
                b = "0";
            }
            while (x != 0)
            {
                b = x % 2 + b;
                x /= 2;
            }
            return b;
        }
        static int dek(string s)
        {
            int x = 0;
            int o = 1;
            char[] c = s.ToCharArray();
            for (int i = s.Length - 1; i >= 0; i--)
            {
                x += int.Parse(c[i].ToString()) * o;
                o *= 2;
            }
            return x;
        }
        static string xor(string a, string b)
        {
            string c = "";
            while (a.Length > b.Length)
            {
                b = "0" + b;
            }
            while (a.Length < b.Length)
            {
                a = "0" + a;
            }
            char[] ca = a.ToCharArray();
            char[] cb = b.ToCharArray();
            for (int i = 0; i < a.Length; i++)
            {
                if ((ca[i] == '1' && cb[i] == '0') || (ca[i] == '0' && cb[i] == '1'))
                {
                    c += '1';
                }
                else
                {
                    c += '0';
                }
            }
            return c;
        }
        static string and(string a, string b)
        {
            string c = "";
            while (a.Length > b.Length)
            {
                b = "0" + b;
            }
            while (a.Length < b.Length)
            {
                a = "0" + a;
            }
            char[] ca = a.ToCharArray();
            char[] cb = b.ToCharArray();
            for (int i = 0; i < a.Length; i++)
            {
                if (ca[i] == '1' && cb[i] == '1')
                {
                    c += '1';
                }
                else
                {
                    c += '0';
                }
            }
            return c;
        }
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] A = Console.ReadLine().Split(' ');
            string[] B = Console.ReadLine().Split(' ');
            int max = 0;
            for (int i = 0; i < N; i++)
            {
                string a1 = "0";
                string b1 = "1";
                for (int j = i; j < N; j++)
                {
                    a1 = xor(a1, bin(A[j]));
                    b1 = and(b1, bin(B[j]));
                    if (dek(a1) * dek(b1) > max)
                    {
                        max = dek(a1) * dek(b1);
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}