#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    int n,i,k,j,ono,onoi,br,max=0;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    for(k=0;k<n;k++)
	{
        ono=0;
        onoi=b[k];
		for(j=k;j<n;j++)
		{
            ono^=a[j];
            onoi&=b[j];
            br=ono*onoi;
			if(br>max)
			{
			    max=br;
            }
        }
    }printf("%d\n", max);

 
	return 0;
}