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] -> Integer
solve n as = (`mod` (10^9+7)) . (calcEachBitResults n) . aggregateBits $ as

aggregateBits :: [Int] -> [Int]
aggregateBits as = map (countBits as) [0..(bitLength as-1)] 

bitLength :: [Int] -> Int
bitLength as = finiteBitSize (maximum as) - countLeadingZeros (maximum as)

countBits :: [Int] -> Int -> Int
countBits as d = length . filter (flip testBit d) $ as

calcEachBitResults :: Int -> [Int] -> Integer
calcEachBitResults n = sum . zipWith (\d x -> 2^d*x) [0..] . map ((\x -> x * (n'-x)).fromIntegral)
  where
    n' = fromIntegral n

input :: [Int]
input = map read.words $ "3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820"