import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)
import Data.Bits
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print . h . V.map (uncurry (*)) . g . map f $ as

h :: V.Vector Int -> Int
h = V.foldr step 0
  where
    step k l = (k + 2 * l) `mod` modulus

g :: [V.Vector Bool] -> V.Vector (Int, Int)
g = foldl (V.zipWith op) (V.replicate 60 (0, 0))
  where
    op (cf, ct) = bool (succ cf, ct) (cf, succ ct)

f :: Int -> V.Vector Bool
f = V.generate 60 . testBit

modulus :: Int
modulus = 10 ^ 9 + 7

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
