while n = gets.to_i
	break if n.zero?
	time_data = Array.new
	waiting_time = [0]
	n.times{ time_data << gets.to_i }
	time_data.sort[0,n-1].each.with_index { |time, i| waiting_time[i+1] = waiting_time[i] + time }
	puts waiting_time.inject(&:+)
end