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