#include <iostream>

int main() {

    int n;
    std::cin >> n;
    int *A = new int[n];
    int *B = new int[n];

    for(int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    for(int i = 0; i < n; i++) {
        std::cin >> B[i];
    }

    int max = A[0] * B[0];

    for(int l = 0; l < n; l++) {
        int aSum = A[l];
        int bSum = B[l];

        int returnVal = aSum * bSum;
        if(returnVal > max) max = returnVal;

        for(int r = l + 1; r < n; r++) {

            aSum = aSum ^ A[r];
            bSum = bSum & B[r];

            returnVal = aSum * bSum;
            if(returnVal > max) max = returnVal;
        }
    }

    std::cout << max << std::endl;
    return 0;
}