import Data.List
import Data.Bits

main = do
  li <- getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  print ans

{-
そのままやったら確実にTLEだろうな…
-}

modulo = 10^9 + 7

compute :: Int -> [Int] -> Int
compute n as = sum [x `xor` y | (x:ys) <- tails as, y <- ys] `mod` modulo
