N = int(input()) if N == 0: print(-1) exit() ans = [] s = 1 for i in reversed(range(61)): if (N >> i) & 1: ans.append((1 << (i+1)) - 1) N = ~N print(len(ans)) print(*ans)