using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class Program
    { 
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] maks = new int[n];
            maks[0] = (a[0] ^ a[0]) * (b[0] & b[0]);
            for (int i = 1; i < n; i++) 
            {
                maks[i] = Math.Max((a[i] ^ a[i]) * (b[i] & b[i]), (a[i] ^ a[i - 1]) * (b[i] & b[i - 1]));
            }
            Console.WriteLine(maks.Max());
        }
    }
}