N, M = map(int, input().split()) counter = 0 sum = 0 A = list(map(int,input().split())) for i in range(N): if A[i] % 2 != 0: counter += 1 sum += A[i] else: if counter >= M: print(sum) counter = 0 sum = 0 if sum != 0: print(sum)