#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define run int teodorfonburgjenasgospodar; cin >> teodorfonburgjenasgospodar; while (teodorfonburgjenasgospodar--)
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define yes cout << "YES\n";
#define no cout << "nO\n";
#define cintienull ios_base::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define inputV(a, n) for(int i = 0; i < n; i++)cin>>a[i];
#define ov(a, n) for(int i = 0; i < n; i++)cout << a[i] << " ";
#define ovr(a, n) for(int i = 0; i < n; i++)cout << a[i] << "\n";
#define InF 1000000000
#define LInF 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007;

using namespace std;

ll solve(int n, const vi& a, const vi& b) {
    vi prefxor(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        prefxor[i] = prefxor[i - 1] ^ a[i - 1];
    }

    ll maxV = 0;
    stack<pii> s;
    for (int i = 0; i < n; ++i) {
        int minb = b[i];
        int start = i;
        while (!s.empty() && s.top().s >= b[i]) {
            auto [prevstart, prevb] = s.top();
            s.pop();
            minb = prevb;
            start = prevstart;

            // ???????? ????????? ?? ????????? ??????
            ll xorV = prefxor[i] ^ prefxor[prevstart];
            maxV = max(maxV, xorV * 1LL * prevb);
        }

        s.emplace(start, b[i]);

        // ???????? ????????? ?? ???????? ??????
        ll xorV = prefxor[i + 1] ^ prefxor[start];
        maxV = max(maxV, xorV * 1LL * b[i]);
    }

    // ???????? ????????? ?? ????????? ????????? ? ?????
    while (!s.empty()) {
        auto [start, minb] = s.top();
        s.pop();
        long long xorV = prefxor[n] ^ prefxor[start];
        maxV = max(maxV, xorV * 1LL * minb);
    }

    return maxV;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    cout << solve(n, a, b) << endl;
    return 0;
}