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

plus :: Int -> Int -> Int
plus a b = mod (a + b) teisu

times :: (Int, Int) -> Int
times x = mod (fst x * snd x) teisu

main :: IO ()
main = do
    n <- getInts
    xa <- getInts
    let tempSum = scanr plus 0 (tail xa)
    let pairs = zip xa tempSum
    let tempTimes = map times pairs
    let r = foldr plus 0 tempTimes
    (putStrLn . show) r
