/// PREFIKSNO STABLO/TRIE ZA A I B PA NEKI DP ???
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[200050], b[200050];
long long A, B, res, maksres;
long long S, M, s_pret, m_pret;
bool a_provera = 1, b_provera = 1;
int main()
{
   //freopen("test.in", "r", stdin);
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   cin >> n;
   for(int i=1; i<=n; i++)
      cin >> a[i];

   for(int i=1; i<=n; i++)
      cin >> b[i];


      maksres = 0;
      for(int i=1; i<=n; i++)
      {
         A = a[i];
         B = b[i];
         res = A * B;
         maksres = max(maksres, res);

         for(int j = i+1; j<=n; j++)
         {
            A = A ^ a[j];
            B = B & b[j];

            res = A * B;
            //cout << A << " " << B << endl;
            maksres = max(maksres, res);
         }
      }

      cout << maksres << endl;
      return 0;

}