package C

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val a = List.fill[Long](n)(sc.nextLong)
  val s = a.scanRight(0L)((x, y) => (x + y) % 1000000007L).drop(1)
  println(a.zip(s).foldLeft[Long](0L)((x, y) => (x + y._1 * y._2) % 1000000007L))
}
