import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Maybe

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  n <- getInt
  xs <- getIntList
  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))


revBitSum :: Integer -> [Integer] -> [Integer]
revBitSum x [] = []
revBitSum  x (y:ys) = (((fromIntegral x) .&. 1) + y):(revBitSum (shiftR x 1) ys)

solve' n xs =
  let eachBitSum = foldr revBitSum (replicate 60 0) xs
  in foldl (\s (i,x) -> (s + 2^i * x * (n-x)) `mod` (10^9 + 7) ) 0 $ zip [0..] $! eachBitSum


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))
