toInt :: (String -> Int)
toInt x = read x ::Int

getInts :: IO [Int]
getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y

products :: [Int] -> [Int] -> [Int]
products xa res
    | xa == [] = res
    | otherwise = products (tail xa) (res ++ [mod (a * (head xa)) 1000000007 | a <- tail xa])

calc :: Int -> Int -> Int
calc a b = mod (a + b) 1000000007

main :: IO ()
main = do
    n <- getInts
    xa <- getInts
    let r = foldr calc 0 (products xa [])
    (putStrLn . show) r
