#include <stdio.h>

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

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

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

    int max_value = 0;

    for (int L = 0; L < N; L++) {
        int current_xor = 0;
        int current_and = ~0;

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

            int value = current_xor * current_and;

            if (value > max_value) {
                max_value = value;
            }
        }
    }

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

    return 0;
}