func main(input1: String = readLine()!, input2: String = readLine()!) {
    let integers = input2.split(separator: " ").map { Int($0)! }
    
    let mod = 1000000007
    var summary = 0
    for i in integers {
        summary += i
        summary %= mod
    }
    var result = 0
    for i in integers {
        summary -= i
        if summary < 0 {
            summary += mod
        }
        result += i * summary
        result %= mod
    }
    print(result)
}

main()