#include <iostream>

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);

	int N;
	std::cin >> N;

	int A[N];
	int B[N];
	for (int i = 0; i < N; ++i)
		std::cin >> A[i];

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

	size_t max = 0;
	size_t res_a;
	size_t res_b;
	for (int l = 0; l < N; ++l) {
		res_a = -1;
		res_b = -1;

		for (int i = l; i < N; ++i) {
			if (res_a == -1) {
				res_a = A[i];
				res_b = B[i]; 
			} else {
				res_a = res_a ^ (A[i]);
				res_b = res_b & (B[i]); 
			}

			if (res_a * res_b > max) 
				max = res_a * res_b;
		}
	}

	std::cout << max;

	return 0;
}