//E
#include <bits/stdc++.h>

using namespace std;

int main() {

    int n; cin >> n;

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

    long long maks = -1e18;

    for (int l = 0; l < n; l++) {
        int xorVr = 0;  
        int andVr = (1 << 30) - 1;  

        for (int r = l; r < n; r++) {
            xorVr ^= a[r];  
            andVr &= b[r];  

            long long trenutnaVr = (long long)xorVr * andVr;

            maks = max(maks, trenutnaVr);
        }
    }

    cout << maks << endl;

    return 0;
}