n,m = map(int,input().split()) an = list(map(int,input().split())) result = [] tmp = [] for i in range(len(an)): #print(an[i]) if an[i]%2==1: tmp.append(an[i]) else: if len(tmp)>=m: result.append(tmp) tmp = [] if len(tmp)>=m: result+=[tmp] for i in result: print(sum(i))