n = int(input()) ans = [] for i in range(n): if 2 ** i > n: break if 1 & (n >> i): ans.append(2 ** i) xor = 0 summ = 0 for v in ans: xor ^= v summ += v if xor == n and summ < 2 * n: print(len(ans)) print(*ans) else: print(-1)