def getPrice v, m
  sum = 0
  v.size.times do |i|
    unless (i + 1) % m == 0 then
      sum += v[i] 
    end
  end
  sum
end

loop do
  n,m = gets.chomp.split(" ").map(&:to_i)
  if (n|m) == 0 then
    break
  end
  vegetable = gets.chomp.split(" ").map(&:to_i).sort!{|a,b| b <=> a}
  puts getPrice(vegetable, m)
end