class Array 
  def each_s(l = 1)
    i = 0
    while i < self.size
      a = slice(i,l)
      yield a
      i += l
    end
  end
end
loop do
  n,m = gets.split.map(&:to_i)
  break if (n|m)==0
  ps = gets.split.map(&:to_i)
  ps.sort!{|a,b| b-a}
  ans = ps.inject(0){|sum,x| sum+x}
    ps.each_s(m) do |arr|
      ans -= arr[-1] if arr.size == m
    end
    puts ans
end