import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toLong)
  def solve() = {
    val mod = (1e9+7).toInt
    val sumArr = A.tail.scanLeft(A.head)(_ + _)
    val sum = A.sum
    (0 until n).foldLeft(0L) { (acc, i) =>
      acc + A(i) * (sum - sumArr(i)) % mod
    } % mod
  }

  println(solve())

}

