n,m=map(int,input().split()) a=list(map(int,input().split())) ans=0 odd =0 for i in a: if i%2 == 0: if ans>0 and odd >= m: print(ans) ans=0 odd=0 else: ans+=i odd+=1 if odd >= m and ans!=0: print(ans)