import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let rs = scanr (+) 0 as
    let zs = zipWith f as (tail rs)
    let ans = (sum zs) `mod` 1000000007
    print ans

f a b = (a * b) `mod` 1000000007