object Main extends App {
  val n = io.StdIn.readInt
  val a = io.StdIn.readLine.split(" ").map(x => x.toLong)
  val s = a.scanRight(0L)((x, y) => x + y).drop(1)
  println(a.zip(s).foldLeft[Long](0L)((x, y) => (x + y._1 * y._2) % 1000000007L))
}