using System;

class Program
{
    static string ubinar(int br)
    {
        string bin = "";
        while (br > 0)
        {
            bin = (br % 2) + bin;
            br /= 2;
        }
        return bin.PadLeft(32, '0');
    }
    static string xorrucno(string bin1, string bin2)
    {
        string res = "";
        for (int i = 0; i < bin1.Length; i++)
        {
            if (bin1[i] == bin2[i])
                res += "0";
            else
                res += "1";
        }
        return res;
    }
    static string andrucno(string bin1, string bin2)
    {
        string res = "";
        for (int i = 0; i < bin1.Length; i++)
        {
            if (bin1[i] == '1' && bin2[i] == '1')
                res += "1";
            else
                res += "0";
        }
        return res;
    }
    static int binudec(string bin)
    {
        int res = 0;
        for (int i = 0; i < bin.Length; i++)
        {
            if (bin[bin.Length - 1 - i] == '1')
            {
                res += (1 << i);
            }
        }
        return res;
    }
    static int nadji(int[] a, int[] b, int n)
    {
        int maks = 0;

        for (int l = 0; l < n; l++)
        {
            string sadxor = ubinar(0);
            string sadand = ubinar(int.MaxValue);

            for (int r = l; r < n; r++)
            {
                sadxor = xorrucno(sadxor, ubinar(a[r]));
                sadand = andrucno(sadand, ubinar(b[r]));
                int sadxorvr = binudec(sadxor);
                int sadandvr = binudec(sadand);
                int sad = sadxorvr * sadandvr;
                if (sad > maks)
                {
                    maks = sad;
                }
            }
        }

        return maks;
    }
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(nadji(a, b, n));
    }
}