object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A = Array.fill(sc.nextInt())(sc.nextLong)
  val sums = A.scanLeft(0L)(_ + _).tail
  println {
    A
      .indices
      .map(i => A(i) * ((sums.last - sums(i)) % 1000000007))
      .fold(0L)((l, r) => (l + r) % 1000000007)
  }
}
