n,m=map(int,input().split()) a=[int(i) for i in input().split()] b=[] for i in range(n): #print(i,len(a)) if a[i]%2==0: if b!=[] and len(b)>=m: print(sum(b)) b=[] else: b+=[a[i]] if i==len(a)-1 and len(b)>=m: print(sum(b)) elif i==len(a)-1 and len(b)