using System;

internal class Program
{
    static long sumaA(long[] x, long a, long b)
    {
        long sum = 0;
        bool c = true;
        for (long i = a; i < b; i++)
        {
            if (c)
            {
                sum += x[i] ^ x[i + 1];
                c = false;
            }
            else sum += sum ^ x[i]; 
        }
        return sum;
    }

    static long sumaB(long[] x, long a, long b)
    {
        long sum = 0;
        bool c = true;
        for (long i = a; i < b; i++)
        {
            if (c)
            {
                sum += x[i] & x[i + 1];
                c = false;
            }
            else sum += sum & x[i];
        }
        return sum;
    }
    static void Main(string[] args)
    {
        long n = Convert.ToInt64(Console.ReadLine());

        long[] A = new long[n];
        string[] stringArray = Console.ReadLine().Split(' ');
        for (int i = 0; i < stringArray.Length; i++)
        {
            A[i] = int.Parse(stringArray[i]);
        }

        long[] B = new long[n];
        string[] stringArray1 = Console.ReadLine().Split(' ');
        for (int i = 0; i < stringArray1.Length; i++)
        {
            B[i] = int.Parse(stringArray1[i]);
        }

        long sum = 0;

        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                long temp = 0;
                temp = sumaA(A, i, j) * sumaB(B, i, j);
                if (sum < temp)
                {
                    sum = temp;
                }
            }
        }
        Console.WriteLine(sum);
    }
}