N, M = map(int, input().split()) A = list(map(int, input().split())) s = 0 j = 0 for i in A: if i % 2 == 0: if j >= M: print(s) s = 0 j = 0 else: s += i j += 1 if j >= M: print(s)