object Main extends App {
  val input1 = readInt
  val input2 = readLine
  val N = input1
  val d_i = input2.split(" ").map(_.toInt)
  val s = d_i.sum
  val result = d_i.foldLeft(0)((l, r) => l + (s - r) * r) / 2
  println(result)
}
