let N = Int(readLine()!)!
let AN = readLine()!.split(separator: " ").compactMap { Int($0) }
let mod = 1000000007

var sumAN = AN.reduce(0) { $0 + $1 }
var sumList: [Int] = []
for i in 0..<N {
    sumAN -= AN[i]
    sumList.append(sumAN)
}

var result = 0
for i in 0..<N {
    result += AN[i] * sumList[i]
    result %= mod
}
print(result)
