object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val _ :: list = List.fill(sc.nextInt())(sc.nextInt()).tails.toList.reverse
  println(list.map { case x :: xs => x * xs.sum }.sum)
}
