import scala.io.StdIn.{readInt, readLine}
import scala.collection.mutable.ListBuffer

object Main extends App {

  val n = readInt()
  val in = readLine().split(' ').map(_.toInt)
  val a = ListBuffer.fill(n)(0)
  val b = ListBuffer.fill(n + 1)(0L)
  val mod = 1000000007

  for (i <- 0 until n) {
    a(i) += in(i)
    b(i + 1) += b(i) + a(i)
  }

  var ans = 0L

  for (i <- 0 until n) {
    val sum = b(n) - b(i + 1) % mod

    ans += a(i) * sum
    ans %= mod
  }
  println(ans)
}
