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

revBitSum' x ys = snd $ foldr (\y (r,zs) -> ((shiftR r 1), ((r .&. 1) + y):zs)) (x,[]) ys

solve' n xs =
  let eachBitSum = reverse $ foldr revBitSum' (replicate 60 0) xs
  in fst $ foldl (\(s,p) x -> ((s + p * x * (n-x)) `mod` (10^9 + 7), p*2 `mod` ((10^9) + 7)) ) (0,1) $ eachBitSum
