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

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