let n = Int(readLine()!)!
let divider = 1000_000_000 + 7
let aArray = readLine()!.split(separator: " ").map{Int($0)!}
var sum = 0
var accumulatedSum = 0
for i in 0..<n-1 {
    let j = n - 1 - i
    accumulatedSum += aArray[j] % divider
    accumulatedSum %= divider
    sum += accumulatedSum * aArray[j-1] % divider
    sum %= divider
}
print(sum)


