let n = Int(readLine()!)!
let a = readLine()!.split(separator:" ").map{Int($0)! % mod}
let mod = 1000000007
var s = 0, s1 = 0
for i in 0..<n-1 {
  s1 += a[n-i-1]
  s1 %= mod
  s += a[n-2-i] * s1
  s %= mod
}
print(s)
