n, m = map(int, input().split()) a = list(map(int, input().split())) l = 0 while l < n: s = 0 r = l while r < n and a[r] % 2: s += a[r] r += 1 if r - l >= m: print(s) l = r else: l += 1