N, M = gets.split.map(&:to_i) A = gets.split.map(&:to_i) s = 0 len = 0 sum = 0 while s < N if A[s].even? puts sum if len >= M s += 1 len = 0 sum = 0 else len += 1 sum += A[s] s += 1 end end if len > 0 puts sum end