def f(a,i=0):s=set(a)-{2**j+1for j in range(i,i+5)};return len(s)<2and s or f(a,i+1)

for test in [[5,9,17,33,829],[9,5,17,829,33],[5,9,177,33,65],[65,129,259,513,1025],[129,259,513,1025,65],[63,129,257,513,1025],[65,129,257,513,4097]]:
	print test
	print f(test)
	print ''