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 Debug.Trace

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]

  print $ solve n as bs 0
  
  where
    solve :: Int -> [Int] -> [Int] -> Int -> Int
    solve n as bs i
      | i <= 28 = ((? (2^i,0)) . odd . sum $ for as' $ \a ->
                      lowerBound bs'' (2*t-a) - lowerBound bs'' (t-a) +
                      lowerBound bs'' (4*t-a) - lowerBound bs'' (3*t-a)
                  ) + solve n as bs (i+1)
      | otherwise = 0
      where
        t = 2^i
        as' = map (`mod`(t*2)) as
        bs' = map (`mod`(t*2)) bs
        bs'' = VU.fromList . sort $ bs'

  
lowerBound :: VU.Vector Int -> Int -> Int
lowerBound arr x = lowerBound' 0 (n-1)
  where
    n = VU.length arr
    lowerBound' l r
      | arr `VU.unsafeIndex` (n-1) < x = n
      | r - l <= 1 = if arr `VU.unsafeIndex` l < x then r else l
      | otherwise = let m = div (l+r) 2 in
                      if arr `VU.unsafeIndex` m < x then
                        lowerBound' m r
                      else
                        lowerBound' l m

