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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    int a[n],b[n];
    int m = 0;
    for ( int i = 0 ; i < n ; i++ ) cin >> a[i];
    for ( int i = 0 ; i < n ; i++ ) cin >> b[i];
    for ( int i = 0 ; i < n ; i++ )
    {
        int c = a[i];
        int d = b[i];
        for ( int j = i+1 ; j < n ; j++ )
        {
            c = c^a[j];
            d = d&b[j];
            m = max(m,c*d);
        }
    }
    cout << m;
	return 0;
}