def solve array
  sum = 0
  (array.size - 1).times do |i|
    sum += array[i] * (array.size  - 1 - i)
  end
  sum
end

while (n = $stdin.gets.to_i) != 0 do
  array = Array.new()
  n.times do
    array << $stdin.gets.to_i
  end
  array.sort!
  puts solve(array)
end