#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N;

unsigned long long iterativno(unsigned int A[], unsigned int B[]) {
  unsigned long long max = 0;
  unsigned int xor, and;

  for (int i = 0; i < N; i++) {
    xor = 0;
    and = 0xffff;

    for (int j = i; j < N; j++) {
      xor ^= A[j];
      and &= B[j];

      unsigned long long provera = (unsigned long long)xor*and;
      if (provera > max) {
        max = provera;
      }
    }
  }

  return max;
}

int main() {
  char ulazni_buffer[1024];
  fgets(ulazni_buffer, sizeof(ulazni_buffer), stdin);
  sscanf(ulazni_buffer, "%i", &N);
  unsigned int A[N], B[N];

  fgets(ulazni_buffer, sizeof(ulazni_buffer), stdin);

  char *broj = strtok(ulazni_buffer, " ");
  int i;
  for (i = 0; i < N && broj != NULL; i++) {
    A[i] = atoi(broj);
    broj = strtok(NULL, " "); // null da bi nastavili od isto mesto
  }

  fgets(ulazni_buffer, sizeof(ulazni_buffer), stdin);
  broj = strtok(ulazni_buffer, " ");

  for (i = 0; i < N && broj != NULL; i++) {
    B[i] = atoi(broj);
    broj = strtok(NULL, " "); // null da bi nastavili od isto mesto
  }

  printf("%llu\n", iterativno(A, B));

  return 0;
}