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 isOdd = True else: ans.append(sum) sum = 0 isOdd = False if isOdd: ans.append(sum) sum = 0 for i in ans: if i != 0: print(i)