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