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.List (unfoldr, transpose)

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

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

g :: [Bool] -> (Int, Int)
g = foldl step (0, 0)
  where
    step (cf, ct) = bool (succ cf, ct) (cf, succ ct)

f :: Int -> [Bool]
f = unfoldr next
  where
    next k = Just (r == 1, q)
      where
        (q, r) = k `divMod` 2

modulus :: Int
modulus = 10 ^ 9 + 7

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