#define _CRT_DISABLE_PERFCRIT_LOCKS
#define ll long long
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int najvecaVrednost(vector<int>& arr1, vector<int>& arr2) 
{
	int res = arr1[0] * arr2[0];
	int maxEnding = arr1[0] * arr2[0];

	for (int i = 1; i < arr1.size(); i++) 
	{
		maxEnding = max((maxEnding ^ arr1[i]) * (maxEnding & arr2[i]), arr1[i] * arr2[i]);
		res = max(res, maxEnding);
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	pair<vector<int>, vector<int>> obaNiza = { {}, {} };
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		obaNiza.first.push_back(t);
	}
	
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		obaNiza.second.push_back(t);
	}

	cout << najvecaVrednost(obaNiza.first, obaNiza.second);
}