N,M=map(int,input().split()) A=[int(i) for i in input().split()] streak=0 wa=0 odds=[] for a in A: if a%2:#odd if streak==0: streak+=1 wa+=a else: streak+=1 wa+=a else: if streak>=M: print(wa) streak=0 wa=0 if streak>=M:print(wa)