N,M = map(int,input().split()) num_list = list(map(int,input().split())) i=0 cnt=0 total=0 while i < len(num_list): a = num_list[i] if a % 2 == 0: if cnt < M: total=0 cnt=0 else: print(total) total=0 cnt=0 i+=1 continue else: cnt+=1 total+=a i+=1