import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val A = readLine().split(" ").map(_.toLong)
  def solve() = {
    val mod = (1e9+7).toInt
    var sum = (0 until n).foldLeft(0L){ (acc, i) =>
      (acc + A(i)) % mod
    }
    (0 until n-1).foldLeft(0L) { (acc, i) =>
      sum -= A(i)
      if(sum < 0) sum += mod
      acc + A(i) * sum % mod
    } % mod
  }

  println(solve())

}

