let () = Scanf.scanf "%d\n" @@ fun n ->
  let darr = Array.make (n+1) 0 in
  let dcum = Array.make (n+1) 0 in
  let sum = ref 0 in
  for i=1 to n do
    Scanf.scanf " %d" @@ fun d ->  darr.(i) <- d; dcum.(i) <- dcum.(i-1) + d
  done;
  for i=1 to n-1 do
    sum := !sum + darr.(i) * (dcum.(n) - dcum.(i))
  done;
  Printf.printf "%d\n" !sum
