n,m = map(int,input().split()) W = list(map(int,input().split())) ans = [] for i in range(n-1): if W[i] == 0: ans.append(0) else: ans.append(1) m -= 1 ans.append(m) print(*ans)