
private fun getLongs(): LongArray {
    return readLine()!!.split(" ").map {it.toLong()}.toLongArray()
}

fun main(){
    getLongs()
    val arr = getLongs()
    print(solver(arr))
}
private const val mod:Long = 1000000000 + 7

private fun modsum(a:Long,b:Long):Long {
    return (a+b) % mod
}
private fun modprod(a:Long,b:Long):Long {
    return (a*b) % mod
}

private fun solver(arr:LongArray):Long {
    // index番目まで足した奴の配列
    val sums = LongArray(arr.size)
    var sum = 0L
    for (i in arr.indices) {
        sum = modsum (sum,arr[i])
        sums[i] = sum
    }
    var total = 0L
    for (i in 1 until arr.size) {
        total = modsum(total, modprod(arr[i],sums[i-1]))
    }
    return total
}
