import Foundation
let n = Int(readLine()!)!

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

var prefixSums: [Int] = .init(repeating: 0, count: a.count + 1)

for i in 0..<a.count {
  prefixSums[i+1] = prefixSums[i] + a[i] 
}

var ans = 0
let mod = 1000000007
for i in 0..<a.count {
  ans = ans + a[i] * (prefixSums.last! - prefixSums[i+1])
  ans = ans % mod
}
print(ans)