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

namespace bitoperation
{
    internal class Program
    {
        static void Main(string[] args)
        {
           uint N=uint.Parse(Console.ReadLine());
            uint[] A=new uint[N];
            uint[] B=new uint[N];
            List<ulong> results = new List<ulong>();
            string s = Console.ReadLine();
            string[] input = s.Split(' ');
            s=Console.ReadLine();
            string[] input2 = s.Split(' ');
            for (int i = 0; i < N; i++) {
                A[i]=uint.Parse(input[i]);
                B[i] = uint.Parse(input2[i]);
            }
            uint tempa;
            uint tempb;
            for (uint L = 0; L < N; L++)
            {
                for (uint R = L; R < N; R++)
                {
                    tempa=A[L];
                    tempb=B[L];
                    for (uint i = L+1; i <= R; i++) {
                        tempa=(tempa)^(A[i]);
                        tempb=(tempb)&(B[i]);
                    }
                    results.Add((ulong)tempa*(ulong)tempb);
                }
            }
            
            Console.WriteLine(results.Max());
        }
    }
}