N,M = map(int,input().split()) s = list(map(int,input().split())) ans = [] sum = 0 for A in s: if A %2 == 1: sum += A else: ans.append(sum) sum = 0 if A == s[-1]: ans.append(sum) sum = 0 for i in ans: if i != 0: print(i)