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

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

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

    var sum = A.reduce(0) { $0 + $1 }

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

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