#include<bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
	int n;cin>>n;
	vector<int>a(n),b(n);
	bool f=0;
	for(int&x:a){cin>>x;if(x!=1){f=0;}}
	for(int&x:b){cin>>x;}
	int m=0;
	for(int i=0;i<n;i++){
		int z1=a[i],z2=b[i];
		m=max(m,z1*z2);
		for(int j=i+1;j<n;j++){
			z1^=a[j];z2&=b[j];
			m=max(m,z1*z2);
		}
	}
	cout<<m<<'\n';
}
int32_t main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int32_t T=1;//cin>>T;
	while(T--) {
		solve();
	}
	return 0;
}/*	if(f){
		vector<vector<int>> p(n+1,vector<int>(33)),p2;
		for(int i=0;i<n;i++){
			p[i]=p[i-1];
			for(int j=0;(1<<j)<=b[i];j++){
				if(b[i]&(1<<j)){
					p[i][j]++;
				}
			}
		}
	}else{*/