import Data.Bits

main = do
  n <- read <$> getLine
  xs <- map read . words <$> getLine
  putStrLn . show $ solve n xs

revBit60 :: Int -> Integer -> [Integer]
revBit60 k x = if k > 60 then [] else ((fromIntegral x) .&. 1):(revBit60 (k+1) (shiftR x 1))

takeFirstSum xss = sum $ map head xss

solve n xs =
  let bitEx = map (revBit60 1) xs
      eachBitSum = calcEachBit bitEx
  in foldl (\s (i,x) -> (s + 2^i * x * (n-x)) `mod` (10^9 + 7) ) 0 $ zip [0..] eachBitSum

calcEachBit xss
  | head xss == [] = []
  | otherwise      = takeFirstSum xss : (calcEachBit (map tail xss))
