
fun power(base: Long, exp: Long, mod: Long): Long {
    return when(exp) {
        0L -> 1
        1L -> base % mod
        else -> power(base * base % mod, exp shr 1, mod) * power(base, exp and 1, mod) % mod
    }
}
fun main() {
    val mod = 1000000007L
    val n = readLine()!!.trim().toInt()
    val num = readLine()!!.trim().split(' ').map(String::toLong).toLongArray()
    val sum = num.sum() % mod
    println(num.map{(it * sum % mod + mod - it * it % mod) % mod}.sum() % mod * power(2, mod - 2, mod) % mod)
}