import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine()
  val d :Array[Int]  = StdIn.readLine().split(" ").map(_.toInt)

  var ans = 0

  d.zipWithIndex.foreach { i =>
    if (i._2 < d.length - 1) ans = ans + d.drop(i._2 + 1).map(_ * i._1).sum
  }

  println(ans)

}
  

