{-# LANGUAGE TypeFamilies #-}

import Control.Monad
import Control.Applicative ((<$>), (<*>))
import Data.List
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Debug.Trace
import Data.Bits

readIntBS = fst . fromJust . BS.readInt
for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map readIntBS . BS.words <$> BS.getLine :: IO [Int]
  bs <- map readIntBS . BS.words <$> BS.getLine :: IO [Int]

  bs' <- VU.thaw . VU.fromList $ bs

  
  print =<< solve n as bs' 28
  
  where
    solve :: Int -> [Int] -> VUM.IOVector Int -> Int -> IO Int
    solve n as bs i
      | i >= 0 = do
          forM_ [0..n-1] $ \j -> VUM.unsafeRead bs j >>= \x -> VUM.unsafeWrite bs j (x `mod` (t*2))
          quickSortMVector bs

          temp <- (forM (map (`mod`(t*2)) as) $ \a -> do
                      x <- lowerBound bs (2*t-a)
                      y <- lowerBound bs (t-a)
                      z <- lowerBound bs (4*t-a)
                      w <- lowerBound bs (3*t-a)
                      return $ x-y+z-w
                  )
          let res = (? (2^i,0)) . odd . sum $ temp

          (res+) <$> solve n as bs (i-1)
      | otherwise = return 0
      where
        t = 2^i
        k = t*2-1

{-# INLINE lowerBound #-}  
lowerBound :: VUM.IOVector Int -> Int -> IO Int
lowerBound arr x = lowerBound' 0 (n-1)
  where
    n = VUM.length arr
    lowerBound' l r = do
      a <- VUM.unsafeRead arr (n-1)
      if a < x then
        return n
        else if r - l <= 1 then do
        b <- VUM.unsafeRead arr l
        return $ if b < x then r else l
        else do
        let m = div (l+r) 2
        c <- VUM.unsafeRead arr m
        if c < x then
          lowerBound' m r
          else
          lowerBound' l m


{-# INLINE quickSortMVector #-}
quickSortMVector :: VUM.IOVector Int -> IO ()
quickSortMVector vec = do
  qsort 0 (n-1)
  where
    n = VUM.length vec
    {-# INLINE median #-}
    median x y z
      | x < y = if y < z then y else if z < x then x else z
      | otherwise = if z < y then y else if x < z then x else z

    {-# INLINE qsort #-}
    qsort l r = do
      when (l < r) $ do
        piv <- median <$> VUM.unsafeRead vec l <*> VUM.unsafeRead vec (l+(r-l)`div`2) <*> VUM.unsafeRead vec r
        (ll,rr) <- aux piv l r
        qsort l (ll-1)
        qsort (rr+1) r

    {-# INLINE findl #-}
    findl piv i = do
      a <- VUM.unsafeRead vec i
      if a < piv then
        findl piv (i+1)
        else
        return i

    {-# INLINE findr #-}
    findr piv i = do
      a <- VUM.unsafeRead vec i
      if a > piv then
        findr piv (i-1)
        else
        return i

    {-# INLINE aux #-}
    aux piv l r = do
      ll <- findl piv l
      rr <- findr piv r

      if rr > ll then do
        VUM.unsafeSwap vec ll rr
        aux piv (ll+1) (rr-1)
        else
        return (ll,rr)
        
