fun main() {
    val mod = 1000000007L.toBigInteger()
    readLine()
    val x = readLine()!!.split(" ").map(String::toBigInteger)
    val s = x.toMutableList()

    (1 until x.size).forEach { i -> s[i] += s[i - 1] }

    x.indices.map { i -> (x[i] * (s.last() - s[i])).rem(mod) }
            .reduce { acc, i ->  (acc + i).rem(mod) }
            .let { println(it) }
}
