#include <bits/stdc++.h>

using namespace std;

int main() {
  unsigned int n, maximum = 0;
  cin >> n;
  unsigned int a[n];
  unsigned int b[n];

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }

  for (int l = 0; l < n; l++) {
    unsigned int lasta = a[l], lastb = b[l];
    for (int r = l + 1; r < n; r++) {
      lasta ^= a[r];
      lastb &= b[r];
      maximum = max(lasta * lastb, maximum);
    }
  }

  cout << maximum << endl;
  return 0;
}