teisu :: Int
teisu = 1000000007

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

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

calc :: [Int] -> Int -> Int
calc xa res
    | xa == [] = res
    | otherwise = do
        let p = mod ((sum . tail) xa) teisu
        let q = mod (head xa * p) teisu
        calc (tail xa) (mod (res + q) teisu)

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