val MOD = 1000000007

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }

    val aaSum = aa.sum()

    var ans = 0L
    var sum = 0L

    for (i in 0 until n-1) {
        sum += aa[i]
        ans += (aa[i] * ((aaSum - sum)%MOD)) % MOD
        ans %= MOD
    }

    println(ans)
}