package abc177.c

object Main extends App {
  val N = io.StdIn.readLine.toInt

  val param = io.StdIn.readLine.split(" ").map(_.toLong)

  val memo = (0 to param.length - 1).foldLeft(Seq(0l)) { (memo, i) => 
    memo :+ (memo(memo.length - 1) + param(i))
  }

  val ret = (0 to param.length - 1).foldLeft(0l) { (acc, i) =>
    val sum = (memo(param.length) - memo(i + 1)) % (1000000000 + 7)
    (acc + (param(i) * sum)) % (1000000000 + 7)
  }


  println(ret)

}

