object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong())

  val mod = 1000000007
  def plus(a: Long, b: Long): Long = (a + b) % mod

  val b = a.scanRight(0L)(plus)
  var ans = 0L

  for {
    i <- 0 until n
  } {
    ans = plus(ans, a(i) * b(i+1))
  }

  println(ans)
}
