def solve(n, m, arr)
  arr.reduce(&:+) - arr.sort.reverse.each_slice(m).to_a.map {|x|
    x.size == m ? x.last : 0
  }.reduce(&:+)
end
def reader
  $stdin.gets.split(" ").map(&:to_i)
end
loop do
  n, m = reader
  break if n == 0 and m == 0
  puts solve(n, m, reader)
end