#include <iostream>
#include <vector>
#include <climits>

using namespace std;


long long nadjiNajvecu(int n, const vector<int>& A, const vector<int>& B) {
    long long maks = LLONG_MIN;

    for (int i = 0; i < n; ++i) {
        int tr_xor = 0;
        int tr_and = INT_MAX;

        for (int j = i; j < n; ++j) {
            tr_xor ^= A[j];
            tr_and &= B[j];
            long long trV = 1LL * tr_xor * tr_and;
            maks = max(maks, trV);
            if (tr_and == 0) {
            	break;	
			}
        }
    }

    return maks;
}

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 << nadjiNajvecu(n, A, B) << endl;
    return 0;
}