import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  n <- readLn :: IO Integer
  as <- map read . words <$> getLine :: IO [Integer]
  print $ mod (sum [x*y|(i,x)<-zip [1..] as, (j,y)<-zip [1..] as, i<j]) (10^9+7)
  
