
object Main extends App {
  val mod = 1000000007
  val sc = new java.util.Scanner(System.in) 
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong())
  var ans = 0L
  var x = 0L
  for (i <- 0 until n) {
    ans =  (ans + a(i) * x) % mod
    x = (x + a(i)) % mod
  }
  println(ans)
}