### main

while true
  n, m = gets.strip.split(' ').map{|s| s.to_i}
  break if n == 0 && m == 0

  ps = gets.strip.split(' ').map{|s| s.to_i}.sort{|a, b| b <=> a}

  sum = 0
  for i in (0...n)
    if ((i + 1) % m != 0)
      sum += ps[i]
    end
  end
  puts sum
end