import itertools n, m = map(int, input().split()) A = list(map(int, input().split())) G = [list(g) for k, g in itertools.groupby(A, key=lambda x: x % 2)] for B in G: if len(B) >= m and B[0] % 2: print(sum(B))