import Data.Char
import Data.List
import Data.Bits
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- head.parseLine <$> BS.getLine
  as <- parseLine <$> BS.getLine
  print $ solve n as
  where
    parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)

solve :: Int -> [Int] -> Int
solve n as = (`mod` (10^9+7)) . sum . calcEachBitResults $ aggregatedBits
  where
    aggregatedBits = map countBits [0..(bitLength-1)] 
    bitLength = finiteBitSize (maximum as) - countLeadingZeros (maximum as)
    countBits d = length . filter (\x -> x .&. (bit d) /=0) $ as
    calcEachBitResults = zipWith (\d x -> 2^d*x) [0..] . map (\x -> x * (n-x))