n, m = map(int, input().split()) a = [0] + list(map(int, input().split())) + [0] last = -1 s = 0 for i in range(n): if a[i] % 2: if last == -1: last = i s += a[i] else: if i - last >= m: print(s) last = -1 s = 0