import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    val b = new ArrayBuffer[Long]
    var n = 0

    while( { n = readInt; n} != 0 ) {
      val line = { for(i<-1 to n) yield readInt }.toArray.sorted
      var ans = 0L
      var total = 0L
      for(i<- 0 until n) {
        ans += total
        total += line(i).toLong
      }
      b.append(ans)
    }

    print(b.mkString("\n")+"\n")
  }
}