fun main() {
    val P = 1000000007L
    val PP: Long = 2*P
    readLine()
    val list = readLine()!!.split(" ").map(String::toLong)
    val sum = list.sum()%PP
    var mod = (sum*sum)%PP - list.map { (it*it)%PP }.sum()%PP
    if(mod<0)
        mod += PP
    println((mod/2)%P)
}