import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n as
  print ans

base = 10^9+7
reg n = mod n base

compute :: Int -> [Int] -> Int
compute n as = fst $ foldr step (0,0) as

step ai (acc,sig) = (reg $ acc + ai * sig, reg $ sig + ai)

{-
A1 * A2 + A1 * A3 + ... + A1 * An = A1 * Σi=2～n Ai
-}
