object Main {
  def main(args: Array[String]): Unit = {
    val num     = scala.io.StdIn.readInt
    var factors = scala.io.StdIn.readLine.split( " " ).map{ _.toLong }

    val mod     = 1000000007
    var rate    = 0L
    var sum     = 0L

    ( 1 until num ).foreach{ i =>
      rate = ( rate + factors( i - 1 ) )%mod
      sum  = ( sum + rate*factors( i ) )%mod
    }
    println( sum )

  }
}