func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func mainC2() {
    let N = readInt()
    let A = readInts()

    var sum = A.reduce(0) { $0 + $1 } % (1000_000_000 + 7)

    var result = 0
    for i in 0..<(N-1) {
        sum = (sum - A[i]) % (1000_000_000 + 7)
        result += A[i] * sum
        result = result % (1000_000_000 + 7)
    }

    print(result % (1000_000_000 + 7))
}
mainC2()