import kotlin.math.pow

fun main(args: Array<String>) {
	readLine()
	val aList = readLine()?.split(" ")?.map {it.toLong()} ?: return
	
	var result: Long = 0
	val mod = ((10.0.pow(9)+7).toLong())
	var sum: Long = aList.sum() % mod
	for (a in aList) {
		sum -= a
		if (sum < 0) sum += mod
		result += a * sum
		result %= mod
	}
	
	println(result)
}