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())
  val cumSum = a.scanLeft(0L)((x, y) => x + y).tail
  val ans = for(i <- 0 until n) yield {
    a(i) * (cumSum(cumSum.length-1) - cumSum(i)) % mod
  }
  println(ans.sum % mod)
}