using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;


namespace ConsoleApp65
{
    internal class Program
    {
        

        static void Main(string[] args)
        {
            int U = int.Parse(Console.ReadLine());

            string L = Console.ReadLine();
            
            int[] l = new int[U]; 
            int[] l1 = new int[U];


            for (int i = 0; i < U; i++) 
            {
                l[i] = int.Parse(L.Split(' ')[i]);
            }

            string L1 = Console.ReadLine();

            for (int i = 0; i < U; i++)
            {
                l1[i] = int.Parse(L1.Split(' ')[i]);
            }

            int O = int.MinValue;
            int R = int.MinValue;


            for (int i = 0; i < U-1; i++)
            {
                O = Math.Max(O , l[i] ^ l[i+1]);
                R = Math.Max(R , l1[i] & l1[i+1]);
            }
            Console.WriteLine(O * R);

        }
    }
}