#include <iostream>
#include <cmath>
#include <list>
#include <vector>
#include <algorithm>
#include <bitset>
#include <string>
#include <set>
#include <map>
#include <queue>
#define ll int64_t
#define int int64_t
#define VI vector<ll>
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define load(a) for (auto& x : a) cin >> x
#define unload(a) for(auto x: a) cout << x << " "

using namespace std;
const int N = 2e5+20; ll A[N], n;

void solve(){
    cin >> n;
    ll prefsum[n+1];
    prefsum[0] = 0;
    bool alla1case = true;
    rep(i,0,n-1){
        ll x; cin >> x;
        prefsum[i+1] = prefsum[i]^x;
        if(x != 1){
            alla1case = false;
        }
    }
    ll bmax = 0;
    rep(i,0,n-1){
        ll x; cin >> x;
        bmax = max(bmax,x);
    }

    if(alla1case){
        cout << bmax << endl;
        return;
    }

    ll amax = 0;
    rep(i,1,n){
        rep(j,i, n){
            ll ax = prefsum[j]^prefsum[i-1];
            amax = max(amax,ax);
        }
    }
    cout << bmax * amax;

    return;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}