#include <stdio.h>
#include <limits.h>

#define MAX_N 200000

int A[MAX_N], B[MAX_N];

int main() {
    int N;
    scanf("%d", &N);
    

    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    for (int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }


    long long max_value = 0;


    for (int L = 0; L < N; L++) {
        int xor_sum = 0;
        int and_sum = ~0;  

        
        for (int R = L; R < N; R++) {
            xor_sum ^= A[R];
            and_sum &= B[R];  

            
            long long value = (long long) xor_sum * and_sum;
            if (value > max_value) {
                max_value = value;
            }
        }
    }


    printf("%lld\n", max_value);

    return 0;
}