import java.io.PrintWriter import scala.collection.mutable.* import scala.io.StdIn.* import scala.util.chaining.* import scala.math.* import scala.reflect.ClassTag import scala.util.* import scala.annotation.tailrec import scala.collection.mutable @main def main = val n = readLine().toLong def solve(target: Long): List[Long] = target match case 0L => Nil case 1L => 1::Nil case _ => val prev = solve(target >> 1).map{_ << 1} val xor = prev.fold(0L){ (acc, v) => acc ^ ((v << 1) - 1)} if xor != target then 1::prev else prev solve(n) match case Nil => println(-1) case result => println(result.length) println(result.mkString(" ")) System.err.println(result.map{i => (i << 1) - 1}.fold(0L){_ ^ _})