import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    bs = scanl modAdd 0 as :: [Int]
  print . foldl modAdd 0 $ zipWith modMul bs as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
