#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n, x, y, z, mult;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(32, 0));
	vector<vector<int>> b(n, vector<int>(32, 0));
	int max = 0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		for (int j = 31; j >= 0; j--) {
			int k = x >> j;
			if (k & 1) {
				a[i][31 - j] = 1;
			}
			else {
				a[i][31 - j] = 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> x;
		for (int j = 31; j >= 0; j--) {
			int k = x >> j;
			if (k & 1) {
				b[i][31 - j] = 1;
			}
			else {
				b[i][31 - j] = 0;
			}
		}
	}
	for(int i = 0; i < n; i++){
		for (int j = i; j < n; j++) {
			vector<int> c(32, 0);
			vector<int> d(32, 1);
			y = 0;
			z = 0;
			mult = 1;
			for (int k = i; k <= j; k++) {
				for (int l = 0; l < 32; l++) {
					c[l] = a[k][l] ^ c[l];
					d[l] = b[k][l] & d[l];
				}
			}
			for (int k = 31; k >= 0; k--) {
				y += c[k] * mult;
				z += d[k] * mult;
				mult *= 2;
			}
			if (max < y * z) {
				max = y * z;
			}
		}
	}
	cout << max;
}