fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    var b = 0L
    val m = (1e9 + 7).toLong()
    a.forEach {
        b = (b + it) % m
    }
    var t = 0L
    0.until(n - 1).forEach {
        b -= a[it]
        if (b < 0) {
            b += m
        }
        t = (t + a[it] * b) % m
    }
    println(t.toString())
}