let N = stdin.ReadLine()
let A = stdin.ReadLine().Split(' ') |> Array.map int64

let MOD = 1000000007L

let mutable sum = 0L
for i in 0 .. A.Length - 1 do
    sum <- sum + A.[i]

let mutable ans = 0L
for i in 0 .. A.Length - 2 do
    sum <- sum - A.[i]
    ans <- (ans + A.[i] * (sum % MOD)) % MOD

printf "%d" ans
