let mod: Int64 = 1_000_000_007

let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map { Int($0)! }

var acc0: Int64 = 0
var acc1: Int64 = 0

for i in a {
  let j = Int64(i)
  acc0 = (acc0 + j) % mod
  acc1 = (acc1 + j * j) % mod
}
acc0 = (acc0 * acc0) % mod

let b = acc0 > acc1 ? acc0 - acc1 : acc0 - acc1 + mod

print((b + (b % 2) * mod) / 2)
