There are $n$ distinct points on a coordinate line, the coordinate of $i$-th point equals to $x_i$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjacent. Note that any subset containing one element satisfies the condition above. Among all these subsets, choose a subset with maximum possible size.

In other words, you have to choose the maximum possible number of points $x_{i_1}, x_{i_2}, \dots, x_{i_m}$ such that for each pair $x_{i_j}$, $x_{i_k}$ it is true that $|x_{i_j} - x_{i_k}| = 2^d$ where $d$ is some non-negative integer number (not necessarily the same for each pair of points).


-----Input-----

The first line contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of points.

The second line contains $n$ pairwise distinct integers $x_1, x_2, \dots, x_n$ ($-10^9 \le x_i \le 10^9$) — the coordinates of points.


-----Output-----

In the first line print $m$ — the maximum possible number of points in a subset that satisfies the conditions described above.

In the second line print $m$ integers — the coordinates of points in the subset you have chosen.

If there are multiple answers, print any of them.


-----Examples-----
Input
6
3 5 4 7 10 12

Output
3
7 3 5
Input
5
-1 2 5 8 11

Output
1
8



-----Note-----

In the first example the answer is $[7, 3, 5]$. Note, that $|7-3|=4=2^2$, $|7-5|=2=2^1$ and $|3-5|=2=2^1$. You can't find a subset having more points satisfying the required property.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Mathematics

Complete search


Solutions:
n = int(input())
l = list(map(int, input().split()))
s = set(l)
ans = [l[0]]
for i in l:
	j = 1
	while j < int(2000000000.0):
		if i + j in s and i + 2 * j in s:
			print('3')
			print(i, i + j, i + 2 * j)
			quit()
		elif i + j in s:
			ans = [i, i + j]
		j *= 2
print(len(ans))
for i in ans:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
f = set(a)
flag = 0
ans = []
li = max(a)
for i in a:
	d = 1
	while i + d <= li:
		x = i + d
		if x in f:
			flag = 1
			ans = [i, x]
			if x + d in f:
				print(3)
				print(i, x, x + d)
				exit(0)
		d *= 2
if flag == 1:
	print(2)
	print(*ans)
else:
	print(1)
	print(a[0])


import sys, random
n = int(input())
l = list(map(int, input().split()))
l.sort()
d = {}
ans = []
for i in range(n):
	d[l[i]] = 1
f = 0
ans.append([l[n - 1]])
for i in range(n - 1):
	curr = l[i]
	for j in range(32):
		try:
			if d[curr + (1 << j)] == 1:
				try:
					if d[curr + (1 << j + 1)] == 1:
						print(3)
						print(curr, curr + (1 << j), curr + (1 << j + 1))
						sys.exit(0)
				except KeyError:
					ans.append([curr, curr + (1 << j)])
		except KeyError:
			continue
for i in ans:
	if len(i) == 2:
		print(2)
		print(i[0], i[1])
		sys.exit(0)
print(1)
print(ans[0][0])


n = int(input())
data = list(map(int, input().split(' ')))
data.sort()
flag3 = False
result3 = []
flag2 = False
result2 = []
mydict = {}
for num in data:
	mydict[num] = '*'
ref_list = [2 ** i for i in range(31)]
for idx in range(31):
	ref = ref_list[idx]
	if idx % 2 == 0:
		data_tmp = []
		for num in data:
			if mydict.get(num + 2 * ref) != None:
				if flag2 == False:
					flag2 = True
					result2 = [num, num + 2 * ref]
				data_tmp.append(num)
				if mydict.get(num + ref) != None:
					flag3 = True
					result3 = [num, num + ref, num + 2 * ref]
					break
	else:
		for num in data_tmp:
			if mydict.get(num + 2 * ref) != None:
				flag3 = True
				result3 = [num, num + ref, num + 2 * ref]
				break
		if flag3:
			break
if flag3:
	print(3)
	print(result3[0], result3[1], result3[2])
elif flag2:
	print(2)
	print(result2[0], result2[1])
else:
	idx = 0
	while idx < 31:
		ref = ref_list[idx]
		for num in data:
			if mydict.get(num + ref) != None:
				flag2 = True
				break
		if flag2:
			break
		idx += 2
	if flag2:
		print(2)
		print(num, num + ref)
	else:
		print(1)
		print(data[0])


import sys
import math
import collections
import heapq
input = sys.stdin.readline
n = int(input())
l = sorted([int(i) for i in input().split()])
l1 = []
p = 1
j = 0
while j < 31:
	l1.append(p)
	p *= 2
	j += 1
d = collections.Counter(l)
t = []
c = 0
for i in d:
	c1 = 0
	for j in range(31):
		if i + l1[j] in d and i + 2 * l1[j] in d:
			k1 = l1[j]
			c1 = 1
			break
	if c1 == 1:
		t = [i, i + k1, i + 2 * k1]
		c = 1
		break
if c == 0:
	c1 = 0
	for i in d:
		for j in range(31):
			if i + l1[j] in d:
				k1 = l1[j]
				c1 = 1
				break
		if c1 == 1:
			t = [i, i + k1]
			c = 1
			break
	if c == 0:
		print(1)
		print(l[0])
	else:
		print(2)
		print(*t)
else:
	print(3)
	print(*t)


n = int(input())
s = set(map(int, input().split()))
m = max(s)
p = 0
for x in s:
	i = 1
	while x + i <= m:
		y = x + i
		if y in s:
			p = (x, y)
			if y + i in s:
				print(3)
				print(x, y, y + i)
				exit()
		i *= 2
if p:
	print(2)
	print(*p)
else:
	print('1\n' + str(m))


from math import sqrt, gcd, ceil, floor, log, factorial
from itertools import permutations, combinations
from collections import Counter, defaultdict

def dist(x1, x2):
	return abs(x1 - x2)

def power2(n):
	return ceil(log(n, 2)) == floor(log(n, 2))
n = int(input())
x = list(map(int, input().split()))
(flag1, flag2, flag3) = (0, 0, 0)
d = Counter(x)
for i in x:
	for po in range(0, 31):
		if d[i - pow(2, po)] > 0 and d[i + pow(2, po)] > 0:
			print(3)
			print(i, i - pow(2, po), i + pow(2, po))
			flag1 = 1
			break
	if flag1 == 1:
		break
if flag1 == 0:
	for i in x:
		for po in range(0, 31):
			if d[i - pow(2, po)] > 0:
				print(2)
				print(i, i - pow(2, po))
				flag2 = 1
				break
			elif d[i + pow(2, po)] > 0:
				print(2)
				print(i, i + pow(2, po))
				flag2 = 1
				break
		if flag2 == 1:
			break
	if flag2 == 0:
		print(1)
		print(max(x))


def check(n, numsDone):
	currDist = 1
	currLen = 1
	currAns = [n]
	while n + currDist <= 10 ** 9 or n - currDist >= -10 ** 9:
		if n + currDist in numsDone and n - currDist in numsDone:
			currLen = 3
			currAns = [n - currDist, n, n + currDist]
			break
		elif n + currDist in numsDone:
			currLen = 2
			currAns = [n, n + currDist]
		elif n - currDist in numsDone:
			currLen = 2
			currAns = [n - currDist, n]
		currDist = currDist << 1
	return currAns
n = int(input())
nums = list(map(int, input().split()))
currLen = 1
currAns = [nums[0]]
numsDone = set(nums)
for i in nums:
	temp = check(i, numsDone)
	if len(temp) > currLen:
		currLen = len(temp)
		currAns = temp
	if len(temp) == 3:
		break
print(currLen)
print(*currAns)


def main():
	input()
	l = list(map(float, input().split()))
	s = set(l)
	b = ma = max(l)
	try:
		while l:
			x = l.pop()
			y = x + 1.0
			while y <= ma:
				if y in s:
					raise TabError
				y = y * 2.0 - x
	except TabError:
		b = x
		l.append(x)
	for x in l:
		y = x + 2.0
		while y <= ma:
			if y in s and (x + y) * 0.5 in s:
				print('3\n%d %d %d' % (x, (x + y) * 0.5, y))
				return
			y = y * 2.0 - x
	if b == ma:
		print('1\n%d' % ma)
		return
	x = 1.0
	while b + x not in s:
		x *= 2.0
	print('2\n%d %d' % (b, b + x))
main()


n = int(input())
numbers = set([int(x) for x in input().split(' ')])
maxbound = max(numbers)
best = []
for x in numbers:
	p = 1
	while x + p <= maxbound:
		newx = x + p
		if newx <= maxbound and newx in numbers:
			best = [x, newx]
			newx2 = newx + p
			if newx2 <= maxbound and newx2 in numbers:
				print(3)
				print(x, newx, newx2)
				exit()
		p *= 2
if len(best) == 0:
	print(1)
	print(numbers.pop())
else:
	print(len(best))
	print(*best)


import math
import sys
import collections
import bisect
import time
import random
from itertools import permutations

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	unique = set(arr)
	poss = False
	for i in arr:
		for j in range(32):
			if i + 2 ** j in unique and i - 2 ** j in unique:
				print(3)
				print(i, i + 2 ** j, i - 2 ** j)
				poss = True
				break
		if poss:
			break
	if poss:
		break
	for i in arr:
		for j in range(32):
			if i + 2 ** j in unique:
				print(2)
				print(i, i + 2 ** j)
				poss = True
				break
		if poss:
			break
	if poss:
		break
	print(1)
	print(arr[0])


import math
n = int(input())
xi = list(map(int, input().split()))
setli = set(xi)
ans = 1
twos = []
three = []
for i in xi:
	if ans == 3:
		break
	li = []
	for ii in range(0, 35):
		if i + 2 ** ii in setli:
			ans = max(ans, 2)
			li.append((i, ii))
			if len(li) > 1:
				if li[-2][1] == ii - 1:
					ans = max(ans, 3)
					three.append((i, ii - 1, ii))
					break
	if len(li) != 0:
		twos.append(li)
print(ans)
if ans == 1:
	print(xi[0])
elif ans == 2:
	print(twos[0][0][0], twos[0][0][0] + 2 ** twos[0][0][1])
elif ans == 3:
	print(three[0][0], three[0][0] + 2 ** three[0][1], three[0][0] + 2 ** three[0][2])


n = int(input().strip())
a = list(map(int, input().strip().split()))
aset = set(a)
flag = False
c = []
for i in range(31):
	c.append(2 ** i)
for i in range(n):
	for j in c:
		b1 = a[i] + j
		b2 = a[i] - j
		if b1 in aset and b2 in aset:
			print(3)
			print(b2, a[i], b1)
			exit(0)
		if not flag:
			if b1 in aset:
				c1 = b1
				c2 = a[i]
				flag = True
if flag:
	print(2)
	print(c1, c2)
else:
	print(1)
	print(a[0])


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	n = int(input())
	x = list(map(int, input().split()))
	s = set(x)
	best = (x[0],)
	for a in s:
		for power in range(0, 40):
			if a + 2 ** power in s:
				if a + 2 * 2 ** power in s:
					best = (a, a + 2 ** power, a + 2 * 2 ** power)
				elif len(best) < 2:
					best = (a, a + 2 ** power)
	print(len(best))
	print(*best)
solve()


n = int(input())
x = list(map(int, input().split()))
setx = set(x)
pw = []
for i in range(32):
	pw.append(2 ** i)
ans = None
for i in range(n):
	for j in range(32):
		a = x[i] - pw[j] in setx
		b = x[i] + pw[j] in setx
		if a and b:
			print(3)
			print(x[i] - pw[j], x[i], x[i] + pw[j])
			exit(0)
		if a:
			ans = (x[i] - pw[j], x[i])
		elif b:
			ans = (x[i], x[i] + pw[j])
if ans is None:
	print(1)
	print(x[0])
else:
	print(2)
	print(*ans)


n = int(input())
x = set(map(int, input().split()))

def solve():
	for i in x:
		for k in range(31):
			if i - (1 << k) in x and i + (1 << k) in x:
				return [i - (1 << k), i, i + (1 << k)]
	for i in x:
		for k in range(31):
			if i + (1 << k) in x:
				return [i, i + (1 << k)]
	for i in x:
		return [i]
z = solve()
print(len(z))
print(*z)


import math
n = int(input(''))
numarr = set(map(int, input().split()))
ans = [0, 0]
m = max(numarr)
found = 0
for x in numarr:
	d = 1
	while x + d <= m:
		if found == 1:
			exit()
		if x + d in numarr:
			y = x + d
			ans[0] = 2
			ans[1] = [x, y]
			if 2 * y - x in numarr:
				print(3)
				print(x, y, 2 * y - x)
				found = 1
			else:
				d *= 2
				continue
		else:
			d *= 2
			continue
if ans == [0, 0]:
	print(1)
	print(m)
else:
	print(2)
	print(ans[1][0], ans[1][1])


n = int(input())
num = sorted(map(int, input().strip().split()))
powers_of_2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]
num_dict = {}
for i in range(n):
	num_dict[num[i]] = num[i]
flag_two = False
flag_three = False
twos = []
threes = []
for i in range(n):
	curr = num[i]
	for power in powers_of_2:
		if num_dict.get(curr + power) is not None:
			flag_two = True
			twos = []
			twos.append(curr)
			twos.append(curr + power)
			if num_dict.get(curr + 2 * power) is not None:
				flag_three = True
				threes = []
				threes.append(curr)
				threes.append(curr + power)
				threes.append(curr + 2 * power)
				break
	if flag_three:
		break
if flag_three:
	print('3')
	print(' '.join(map(str, threes)))
elif flag_two:
	print('2')
	print(' '.join(map(str, twos)))
else:
	print('1')
	print(num[0])


n = int(input())
li = list(map(int, input().split()))
lis = set(li)
p = [2 ** i for i in range(40)]
x = None
for i in lis:
	c = 0
	ind = 0
	for j in range(35):
		ss = i + p[j]
		if ss in lis:
			if ind != 0:
				print('3')
				print(i, c, ss)
				exit()
			if not x:
				x = (i, ss)
			ind = 1
			c = ss
		else:
			ind = 0
if x:
	print('2')
	print(x[0], x[1])
else:
	print('1')
	print(li[0])


def main():
	_ = int(input())
	X = {int(i) for i in input().split()}
	ans = []
	bi = [1 << k for k in range(60)]
	for x in X:
		for b in bi:
			if len(ans) < 3 and x + b in X and (x + b + b in X):
				ans = [x, x + b, x + 2 * b]
			elif len(ans) < 2 and x + b in X:
				ans = [x, x + b]
			elif len(ans) < 2 and x + b + b in X:
				ans = [x, x + 2 * b]
	if not ans:
		ans.append(X.pop())
	print(len(ans))
	print(*ans)
main()


visit = dict()
exist = dict()
n = int(input())
x = sorted(map(int, input().split()))
limit = max(x)
for (n, i) in enumerate(x):
	exist[i] = n + 1
(ans, ans2) = (1, [x[0]])
for i in range(len(x)):
	if visit.get(x[i], 0):
		continue
	j = 1
	while x[i] + j <= limit:
		visit[x[i] + j] = True
		if exist.get(x[i] + j, 0):
			if ans == 1:
				ans = 2
				ans2 = [x[i], x[i] + j]
			if j != 1 and exist.get(x[i] + j // 2, 0):
				print(3)
				print(x[i] + j, x[i], x[i] + j // 2)
				return
		j *= 2
if ans == 2:
	print(2)
	print(ans2[0], ans2[1])
else:
	print(1)
	print(x[0])


n = int(input())
a = []
_2 = [1]
FS = lambda x: x in S

def F(x):
	(l, r) = (0, len(a) - 1)
	while l < r - 1:
		mid = l + r >> 1
		if a[mid] == x:
			return True
		elif a[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	else:
		return a[l] == x or a[r] == x
for i in range(30):
	_2.append(_2[i] * 2)
for i in map(int, input().split()):
	a.append(i)
S = set(a)
ans = 1
A = [0, a[0], 0]
for i in a:
	if ans == 3:
		break
	for j in _2:
		if ans == 3:
			break
		if FS(i - j):
			if ans <= 2:
				ans = 2
				A[0] = i - j
				A[1] = A[2] = i
			if FS(i + j):
				ans = 3
				A[2] = i + j
				break
print(ans)
if ans == 3:
	print(*A)
else:
	print(A[1], end=' ')
	if ans == 2:
		print(A[0] + A[2] - A[1])
	else:
		print()


n = int(input())
a = set(map(int, input().split()))
ans = []
f = 0
for i in a:
	c = 1
	for p in range(31):
		if i + c in a:
			ans = [i, i + c]
			if i + c * 2 in a:
				print(3)
				print(i, i + c, i + c * 2)
				f = 1
				break
		c *= 2
	if f:
		break
if f == 0:
	if ans:
		print(2)
		print(*ans)
	else:
		print(1)
		print(min(a))


from functools import cmp_to_key
import sys

def getIntList():
	return list(map(int, input().split()))
n = int(input())
nz = getIntList()
ns = set(nz)
r2 = None
pow2 = [2 ** i for i in range(40)]
for x in ns:
	last = 0
	flag = False
	for i in range(32):
		t = x + pow2[i]
		if t in ns:
			if flag:
				print(3)
				print(x, last, t, sep=' ')
				sys.exit()
			if not r2:
				r2 = (x, t)
			flag = True
			last = t
		else:
			flag = False
if r2:
	print(2)
	print(r2[0], r2[1])
else:
	print(1)
	print(nz[0])


n = int(input())
l = [int(i) for i in input().split()]
from collections import Counter
c = Counter(l)
for i in l:
	for j in range(32):
		if c[i + (1 << j)] and c[i - (1 << j)]:
			print(3)
			print(i - (1 << j), i, i + (1 << j))
			exit()
for i in l:
	for j in range(32):
		if c[i + (1 << j)]:
			print(2)
			print(i, i + (1 << j))
			exit()
print(1)
print(max(l))


n = int(input())
L = [int(x) for x in input().split()]
D = {}
for i in L:
	D[i] = 1
best = 1
guy = None
for i in L:
	for j in range(0, 32):
		temp = 1 + (i + 2 ** j in D) + (i - 2 ** j in D)
		if temp > best:
			best = temp
			guy = (i, j)
if best == 3:
	print(3)
	(i, j) = guy
	print(i - 2 ** j, i, i + 2 ** j)
elif best == 2:
	print(2)
	(i, j) = guy
	if i + 2 ** j in D:
		print(i, i + 2 ** j)
	else:
		print(i - 2 ** j, i)
else:
	print(1)
	print(L[0])


from __future__ import print_function
import sys
import math
import os.path

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def ni():
	return map(int, input().split())

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

def nia():
	return list(map(int, input().split()))

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}
(n,) = ni()
xa = nia()
x = set(xa)

def solve():
	mlist = [xa[0]]
	dis = 1
	for mu2 in range(32):
		for a in x:
			if a + dis in x:
				if a + dis + dis in x:
					return [a, a + dis, a + dis + dis]
				mlist = [a, a + dis]
		dis <<= 1
	return mlist
res = solve()
print(len(res))
print(toString(res))


import math
import heapq, bisect
import sys
from collections import deque
from fractions import Fraction
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
n = int(input())
l = list(map(int, input().split()))
po = [pow(2, i) for i in range(31)]
d = dict()
for i in range(n):
	if l[i] not in d:
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1
tot = 1
er = 0
er1 = 0
for i in range(n):
	for j in range(31):
		r = 0
		r1 = 0
		if l[i] + po[j] in d:
			r = d[l[i] + po[j]]
		if j < 30 and l[i] + po[j + 1] in d:
			r1 = d[l[i] + po[j + 1]]
		tot = max(tot, r + r1 + 1)
		if r + r1 + 1 == tot:
			if r > 0:
				er = po[j]
			else:
				er = 0
			if r1 > 0:
				er1 = po[j + 1]
			else:
				er1 = 0
			st = i
print(tot)
ans = [l[st]]
for i in range(d[l[st] + er]):
	ans.append(l[st] + er)
for i in range(d[l[st] + er1]):
	ans.append(l[st] + er1)
print(*ans[:tot], sep=' ')


from ntpath import realpath
import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = inp()
l = sorted(li())
ans = 1
val = [l[0]]
s = set(l)
for i in range(n):
	for j in range(33):
		(a, b) = (l[i] - (1 << j), l[i] + (1 << j))
		if a in s and b in s:
			print(3)
			print(a, l[i], b)
			exit()
		if a in s and b not in s:
			ans = 2
			val = [a, l[i]]
		if a not in s and b in s:
			ans = 2
			val = [l[i], b]
pr(ans)
print(*val)


from sys import stdin

def main():
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	ar.sort()
	lk = {ar[i]: i for i in range(n)}
	dp = [[1 for _ in range(61)] for _ in range(n)]
	max_size = 1
	max_val = ar[0]
	diff = -1
	for i in range(1, n):
		for j in range(0, 61):
			tmp = ar[i] - (1 << j)
			if tmp in lk:
				dp[i][j] = max(dp[i][j], dp[lk[tmp]][j] + 1)
			if dp[i][j] <= 3:
				if dp[i][j] > max_size:
					max_size = dp[i][j]
					max_val = ar[i]
					diff = 1 << j
			if max_size == 3:
				break
		if max_size == 3:
			break
	print(max_size)
	if max_size == 1:
		print(ar[0])
	else:
		ans = []
		curr = max_val
		for i in range(max_size):
			ans.append(curr)
			curr -= diff
		print(*ans)
main()


n = int(input())
a = set(map(int, input().split()))
m = max(a)
cur = ()
v = 0
for i in a:
	j = 1
	while i + j <= m:
		if i + j in a:
			cur = (i, i + j)
			v = 1
			if i + 2 * j in a:
				print(3)
				print(i, i + j, i + 2 * j)
				exit()
		j *= 2
if v:
	print(2)
	print(*cur)
else:
	print(1)
	print(m)


from sys import stdin, stdout
from collections import Counter
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = set(iia())
res = 1
sel = set([next(iter(arr))])
for i in arr:
	for j in range(35):
		ele = set([i])
		if i + 2 ** j in arr:
			ele.add(i + 2 ** j)
		if i - 2 ** j in arr:
			ele.add(i - 2 ** j)
		if len(ele) > res:
			res = len(ele)
			sel = ele
print(res)
print(*sel)


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
for _ in range(1):
	n = nmbr()
	a = set(lst())
	lim = max(a)
	f = 0
	for x in a:
		p2 = 1
		while x + 2 * p2 <= lim:
			f = 0
			if x in a and x + p2 in a and (x + 2 * p2 in a):
				ans = [x, x + p2, x + 2 * p2]
				f = 1
				break
			if f:
				break
			p2 *= 2
		if f:
			break
	if f:
		print(3)
		print(*ans)
		continue
	for x in a:
		p2 = 1
		while x + p2 <= lim:
			f = 0
			if x in a and x + p2 in a:
				ans = [x, x + p2]
				f = 1
				break
			p2 *= 2
		if f:
			break
	if f:
		print(2)
		print(*ans)
		continue
	print(1)
	print(list(a)[0])


import math
powers = [2 ** i for i in range(0, 31)]

def f(s):
	for k in s:
		for j in powers:
			a = k - j
			b = k + j
			if a in s and b in s:
				return [a, k, b]
	for k in s:
		for j in powers:
			b = k + j
			if b in s:
				return [k, b]
	return [next(iter(s))]

def main():
	_ = input()
	x = set((int(x) for x in input().split()))
	res = f(x)
	print(len(res))
	print(' '.join((str(x) for x in res)))
main()


powersoftwo = [2 ** i for i in range(0, 34)]
N = int(input())
array = [int(x) for x in input().split()]
checker = set(array)
total = -1
for i in array:
	for j in powersoftwo:
		z = 1
		a = 1
		b = 1
		if i - j in checker:
			z += 1
			a += 1
		if j + i in checker:
			z += 1
			b += 1
		total = max(z, total)
		if total == z:
			if a == 2:
				something = [i, i - j]
			if b == 2:
				something = [i, i + j]
			if a == 2 and b == 2:
				something = [i, i + j, i - j]
print(total)
if total > 1:
	print(*something)
else:
	print(array[0])


from math import pow
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict()
for i in arr:
	d[i] = 1
result = []
flag = 0
for i in range(n):
	if flag == 1:
		break
	for j in range(31):
		x = pow(2, j)
		y1 = arr[i] - x
		y2 = arr[i] + x
		if y1 in d and y2 in d:
			result = [int(y1), arr[i], int(y2)]
			flag = 1
			break
		elif y2 in d and len(result) < 2:
			result = [arr[i], int(y2)]
		elif y1 in d and len(result) < 2:
			result = [arr[i], int(y1)]
if len(result) == 0:
	print(1)
	print(arr[0])
else:
	print(len(result))
	print(*result)


pow2 = dict()
curr = 1
z = 10 ** 9
while curr < 2 * z + 5:
	pow2[curr] = 1
	curr = curr * 2
n = int(input())
l = input().split()
li = [int(i) for i in l]
hashi = dict()
for i in li:
	hashi[i] = 1
done = 0
for i in pow2:
	for j in li:
		if j + i in hashi and j + 2 * i in hashi:
			print(3)
			print(j, j + i, j + 2 * i)
			done = 1
			quit()
for i in pow2:
	for j in li:
		if j + i in hashi:
			print(2)
			print(j, j + i)
			done = 1
			quit()
print(1)
print(li[0])


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = [(v, i) for (i, v) in enumerate(a)]
b.sort(key=lambda x: (x[0], x[1]))
ans = 0
(ans_start, ans_range) = ((-1, -1), -1)
for bit in range(32):
	R = 1 << bit
	d = defaultdict(list)
	for (v, i) in b:
		if not d[v % R]:
			d[v % R].append((v, i))
		elif d[v % R][-1][0] != v:
			d[v % R].append((v, i))
	for modular in d.keys():
		stack = []
		vec = d[modular]
		while vec:
			(number, index) = vec.pop()
			stack.append((number, index))
			if not vec:
				if len(stack) > ans:
					ans = len(stack)
					ans_range = R
					ans_data = stack.copy()
				stack.clear()
				continue
			else:
				(next_number, next_index) = vec[-1]
				if next_number == number - R:
					continue
				else:
					if len(stack) > ans:
						ans = len(stack)
						ans_range = R
						ans_data = stack.copy()
					stack.clear()
if ans > 3:
	ans = 3
	ans_data = ans_data[:3]
print(ans)
ans_data.sort(key=lambda x: x[1])
print(*[v[0] for v in ans_data])


n = int(input())
listNum = sorted(list(map(int, input().split())))
setNum = set(listNum)
powTwo = list(map(lambda x: 2 ** x, range(0, 32)))
found2 = False
found3 = False
res = [0, 0, 0]
for powNum in powTwo:
	for num in listNum:
		if found3:
			break
		if num + powNum in setNum:
			found2 = True
			if found3 == False:
				res[0] = num
				res[1] = num + powNum
			if num + 2 * powNum in setNum:
				found3 = True
				res[0] = num
				res[1] = num + powNum
				res[2] = num + 2 * powNum
if found3:
	print(3)
	print(res[0], res[1], res[2])
elif found2:
	print(2)
	print(res[0], res[1])
else:
	print(1)
	print(listNum[0])


from sys import exit
n = int(input())
a = list(map(int, input().strip().split()))
b = set(a)
for i in range(n):
	for j in range(0, 31):
		if a[i] - 2 ** j in b and a[i] + 2 ** j in b:
			print(3)
			print(a[i], a[i] - 2 ** j, a[i] + 2 ** j)
			exit()
for i in range(n):
	for j in range(0, 31):
		if a[i] - 2 ** j in b:
			print(2)
			print(a[i], a[i] - 2 ** j)
			exit()
		else:
			continue
print(1)
print(a[0])


n = int(input())
nums = list(map(int, input().split(' ')))
nums = sorted(nums)
power = [2 ** i for i in range(33)]

def search(x):
	low = 0
	high = len(nums)
	while low < high - 1:
		mid = (low + high) // 2
		if x > nums[mid]:
			low = mid
		elif x < nums[mid]:
			high = mid
		elif x == nums[mid]:
			return x
	return None
best = []
for i in power:
	for j in nums:
		result = []
		result.append(j)
		if search(j + i) is not None:
			result.append(j + i)
		if search(j + 2 * i) is not None:
			result.append(j + 2 * i)
		if len(result) > len(best):
			best = result
print(len(best))
print(' '.join(map(str, best)))


st = set([])
n = int(input())
arr = map(int, input().split())
maxn = int(1000000000.0)
ans = 0
lol1 = lol2 = 0
for i in arr:
	st.add(i)
for i in st:
	p = 1
	while i + p <= maxn:
		if i + p in st:
			if i + p + p in st:
				print(3)
				print(i, end=' ')
				print(i + p, end=' ')
				print(i + p + p)
				exit(0)
			else:
				ans = 2
				lol1 = i
				lol2 = i + p
		p *= 2
if ans == 2:
	print(2)
	print(lol1, end=' ')
	print(lol2)
else:
	print(1)
	print(st.pop())


from sys import stdin

def bin_search(A, val) -> int:
	left_b = 0
	right_b = len(A) - 1
	while left_b < right_b:
		mid = left_b + right_b >> 1
		if A[mid] > val:
			right_b = mid - 1
		elif A[mid] < val:
			left_b = mid + 1
		else:
			return mid
	ans = right_b if A[right_b] == val else -1
	return ans

def print_ans(ans) -> None:
	print(len(ans))
	print(*ans)

def main() -> None:
	n = int(input())
	A = [int(i) for i in stdin.readline().split()]
	A.sort()
	max_gap = abs(A[-1] - A[0])
	if max_gap == 0:
		max_gap = 1
	ans = []
	gap = 1
	temp = []
	while gap <= max_gap:
		for a in A:
			temp = []
			temp.append(a)
			b = a + gap
			c = b + gap
			if bin_search(A, b) != -1:
				temp.append(b)
			if bin_search(A, c) != -1:
				temp.append(c)
			ans = max(ans, temp, key=len)
			if len(ans) == 3:
				print_ans(ans)
				return
		gap <<= 1
	print_ans(ans)
main()


n = int(input())
x = list(map(int, input().split()))
powers = [2 ** i for i in range(31)]
ca = []
d = {}
for i in x:
	d[i] = 1
for i in d:
	for j in powers:
		if i + j in d:
			if len(ca) == 0:
				ca = [i, i + j]
			if i + j + j in d:
				print(3)
				print(i, i + j, i + j + j)
				exit()
if len(ca) > 1:
	print(2)
	print(ca[0], ca[1])
	exit()
print(1)
print(x[0])


from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from math import sqrt, gcd

def read():
	return list(map(int, input().strip().split()))
ans_ = []
t_p = [2 ** i for i in range(31)]
n = int(input())
arr = Counter(read())
d = defaultdict(int)
m = 1
ans_lis = [list(arr.keys())[0]]
for i in arr:
	for j in t_p:
		(a, b, c) = (i, i + j, i + 2 * j)
		s = (arr[a] > 0) + (arr[b] > 0) + (arr[c] > 0)
		if s > m:
			m = s
			ans_lis = [x for x in [a, b, c] if arr[x]]
ans_.append(m)
t = ''
for i in ans_lis:
	t += str(i) + ' '
ans_.append(t)
for i in ans_:
	print(i)


n = int(input())
arr = [int(j) for j in input().split()]
arr.sort()
ans = [arr[0]]
ma = [1, ans]
arr = set(arr)
for x in arr:
	two = 1
	while x + two < 10 ** 10:
		if x + two in arr:
			ans = [x, x + two]
			if ma[0] < 2:
				ma = [2, ans]
			if x + 2 * two in arr:
				ans = [x, x + two, x + 2 * two]
				if ma[0] < 3:
					ma = [3, ans]
			two *= 2
		else:
			two *= 2
print(ma[0])
print(*ma[1])


n = int(input())
l = list(map(int, input().split()))
ka = set(l)
go = set()
for i in range(33):
	go.add(1 << i)
ans = []
flag = 0
yo = []
for j in l:
	count = 0
	for i in range(32):
		if j + (1 << i) in ka:
			if flag != 1:
				flag = 1
				yo = [j, j + (1 << i)]
			for k in range(32):
				if j + (1 << i) + (1 << k) in l and abs(j + (1 << i) + (1 << k) - j) in go:
					print(3)
					ans = [j, j + (1 << i) + (1 << k), j + (1 << i)]
					print(*ans)
					exit()
if flag == 1:
	print(2)
	print(*yo)
else:
	print(1)
	print(l[0])


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
n = I()
a = sorted(R())
d = defaultdict(int)
for i in a:
	d[i] = 1
mx = max(a)
ans = [a[0]]
ln = 1
for i in a:
	p = 1
	b = [i]
	x = 1
	while i + x <= mx:
		if d[i + x]:
			p += 1
			b += (i + x,)
		else:
			p = 1
			b = [i]
		if p > ln:
			ln = p
			ans = b.copy()
		if ln == 3:
			print(ln)
			print(*ans)
			exit()
		x <<= 1
print(ln)
print(*ans)


n = int(input())
x = list(map(int, input().split()))
ans = tuple([x[0]])
x = set(x)
d = set()
tmp = 1
while tmp <= 10 ** 10:
	d.add(tmp)
	tmp *= 2
for a in x:
	for b in d:
		if a + b in x and a - b in x:
			print(3)
			print(a, a + b, a - b)
			exit(0)
		elif a + b in x:
			ans = (a, a + b)
print(len(ans))
print(*ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
from collections import deque
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	a.sort()
	ans = []
	for i in range(n):
		for j in range(31):
			tmp = [a[i]]
			x = a[i] + 2 ** j
			y = a[i] + 2 ** (j + 1)
			if x in s:
				tmp.append(x)
			if y in s:
				tmp.append(y)
			if len(tmp) > 1:
				if len(ans) == 0:
					ans.append(tmp)
				elif len(tmp) > len(ans[0]):
					ans[0] = tmp
	if len(ans) == 0:
		print(1)
		print(a[0])
		return
	if len(ans[0]) == 2:
		print(2)
		print(ans[0][0], ans[0][1])
		return
	if len(ans[0]) == 3:
		print(3)
		print(ans[0][0], ans[0][1], ans[0][2])
		return
main()


input()
a = set(map(int, input().split()))
m = max(a)
t = []
for x in a:
	d = 1
	while x + d <= m:
		if x + d in a:
			t = [x, x + d]
			if x + 2 * d in a:
				print(3)
				print(x, x + d, x + 2 * d)
				exit()
		d *= 2
if t:
	print(2)
	print(*t)
else:
	print(1)
	print(m)


def main():
	n = int(input())
	X = list(map(int, input().split()))
	k = 2
	flag = True
	K = [0] * 2
	T = [k ** i for i in range(32)]
	X_dict = dict.fromkeys(X)
	for i in range(n):
		for j in T:
			if X[i] - j in X_dict and X[i] + j in X_dict:
				print(3)
				print(X[i], X[i] - j, X[i] + j)
				return
			if flag:
				if X[i] - j in X_dict:
					K[:] = (X[i] - j, X[i])
					flag = False
				if X[i] + j in X_dict:
					K[:] = (X[i] + j, X[i])
					flag = False
	if not flag:
		print(2)
		print(*K)
		return
	print(1)
	print(X[0])
main()


N = int(input())
s = list(map(int, input().split()))
s.sort()
d = {}
for x in s:
	d[x] = 1
i = 1
ans = []
while i < 1e+18:
	for x in s:
		t = []
		if d.get(x + i, 0) == 1:
			t = [x, x + i]
		if d.get(x + 2 * i, 0) == 1:
			t.append(x + 2 * i)
		if len(t) > len(ans):
			ans = t
		if len(ans) == 3:
			print(3)
			print(*ans)
			exit(0)
	i *= 2
if len(ans) < 2:
	ans = [s[0]]
print(len(ans))
print(*ans)


import sys
n = int(input())
s = list(map(int, input().split()))
st = set()
for i in s:
	st.add(i)
p = set()
pw = []
for i in range(31):
	p.add(2 ** i)
	pw.append(2 ** i)
for i in range(n):
	for j in range(len(pw)):
		if s[i] + pw[j] in st:
			if s[i] - pw[j] in st:
				print(3)
				print(s[i] - pw[j], s[i], s[i] + pw[j])
				sys.exit()
			if s[i] + pw[j] + pw[j] in st:
				print(3)
				print(s[i], s[i] + pw[j], s[i] + pw[j] + pw[j])
				sys.exit()
		if s[i] - pw[j] in st:
			if s[i] + pw[j] in st:
				print(3)
				print(s[i] - pw[j], s[i], s[i] + pw[j])
				sys.exit()
			if s[i] - pw[j] - pw[j] in st:
				print(3)
				print(s[i], s[i] - pw[j], s[i] - pw[j] - pw[j])
				sys.exit()
for i in range(n):
	for j in range(len(pw)):
		if s[i] + pw[j] in st:
			print(2)
			print(s[i], s[i] + pw[j])
			sys.exit()
		if s[i] - pw[j] in st:
			print(2)
			print(s[i], s[i] - pw[j])
			sys.exit()
print(1)
print(s[0])


n = int(input())
(*a,) = map(int, input().split())
s = set(a)

def solve(x, s):
	p = 1
	ret = [x]
	for d in range(32):
		if x + p in s:
			if x + 2 * p in s:
				return [x, x + p, x + 2 * p]
			if x - p in s:
				return [x - p, x, x + p]
			ret = [x, x + p]
		elif x - p in s:
			if x - 2 * p in s:
				return [x - 2 * p, x - p, x]
			ret = [x - p, x]
		p *= 2
	return ret
best = []
for x in a:
	bestx = solve(x, s)
	if len(bestx) > len(best):
		best = bestx
print(len(best))
print(' '.join(map(str, best)))


import sys

def solve(io):
	N = io.readInt()
	X = io.readIntArray(N)
	has = set(X)
	best = (X[0],)
	for v in X:
		for b in range(0, 31):
			p = 1 << b
			a = v + p
			if a in has:
				if len(best) < 2:
					best = (v, a)
				b = a + p
				if b in has and len(best) < 3:
					best = (v, a, b)
					break
	io.println(len(best))
	io.printlnArray(best)

class IO:
	input = None
	output = None

	def __init__(self, inputStream, outputStream):
		self.input = inputStream
		self.output = outputStream

	@staticmethod
	def isSpaceChar(c):
		return c == ' ' or c == '\n' or c == '\x00' or (c == '\r') or (c == '\t')

	@staticmethod
	def isLineBreakChar(c):
		return c == '\n' or c == '\x00' or c == '\r'

	def readChar(self):
		return self.input.read(1)

	def readString(self):
		c = self.readChar()
		while IO.isSpaceChar(c):
			c = self.readChar()
		sb = []
		while not IO.isSpaceChar(c):
			sb.append(c)
			c = self.readChar()
		return ''.join(sb)

	def readLine(self):
		c = self.readChar()
		while IO.isSpaceChar(c):
			c = self.readChar()
		sb = []
		while not IO.isLineBreakChar(c):
			sb.append(c)
			c = self.readChar()
		return ''.join(sb)

	def readInt(self):
		c = self.readChar()
		while IO.isSpaceChar(c):
			c = self.readChar()
		sgn = 1
		if c == '-':
			sgn = -1
			c = self.readChar()
		res = 0
		while not IO.isSpaceChar(c):
			res = res * 10 + ord(c) - 48
			c = self.readChar()
		return sgn * res

	def readFloat(self):
		return float(self.readString())

	def readStringArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readString())
		return arr

	def readIntArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readInt())
		return arr

	def readFloatArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readFloat())
		return arr

	def print(self, s):
		self.output.write(str(s))

	def println(self, s):
		self.print(s)
		self.print('\n')

	def printlnArray(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flushOutput(self):
		self.output.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flushOutput()


n = int(input())
lst = [int(i) for i in input().split()]
s = set(lst)

def degrees():
	(result, count) = ([lst[0]], 1)
	for i in range(32):
		for elem in s:
			if elem + count in s:
				if elem + 2 * count in s:
					return [elem, elem + count, elem + 2 * count]
				result = [elem, elem + count]
		count <<= 1
	return result
answer = degrees()
print(len(answer))
print(*answer)


n = int(input())
arr = set(map(int, input().split()))

def solve():
	for i in arr:
		for k in range(31):
			if i - (1 << k) in arr and i + (1 << k) in arr:
				return [i - (1 << k), i, i + (1 << k)]
	for i in arr:
		for k in range(31):
			if i + (1 << k) in arr:
				return [i, i + (1 << k)]
	for i in arr:
		return [i]
lst = solve()
print(len(lst))
print(*lst)


from sys import stdin, stdout

def rint():
	return list(map(int, stdin.readline().split()))
n = int(input())
x = set(rint())
x_list = list(x)
x_list.sort()
max_len = 1
for i in range(len(x_list)):
	start = x_list[i]
	for j in range(0, 1000):
		candidate = [start]
		next = start + 2 ** j
		if next > x_list[-1]:
			break
		if next in x:
			candidate.append(next)
			next = start + 2 ** (j + 1)
			if next in x:
				candidate.append(next)
				print(3)
				print(*candidate)
				return
			else:
				ans = candidate
				max_len = 2
if max_len == 2:
	print(2)
	print(*ans)
else:
	print(1)
	print(x_list[0])


n = int(input())
a = [int(i) for i in input().split()]
d = {}
power = [2 ** i for i in range(31)]
ans = []
for i in a:
	d[i] = 0
for num in d.keys():
	for p in power:
		if num + p in d:
			ans = [num, num + p]
			if num + p + p in d:
				print(3)
				ans.append(num + p + p)
				print(*ans)
				exit()
if ans:
	print(2)
	print(*ans)
else:
	print(1)
	print(a[0])


n = int(input())
a = list(map(int, input().split()))
b = set(a)
e = []
for i in range(n):
	c = [a[i]]
	for j in range(35):
		d = []
		p = a[i]
		d.append(p)
		q = 2 ** j
		for k in range(2):
			if p + q in b:
				p = p + q
				d.append(p)
		if len(d) > len(c):
			c = d
	e.append(c)
p = e[0]
for i in e:
	if len(i) > len(p):
		p = i
print(len(p))
print(*p)


def main():
	input()
	s = set(map(int, input().split()))
	b = mi = min(s)
	for x in s:
		(four, y, z) = (4, x - 1, x - 2)
		while mi <= y:
			if y in s:
				if z in s:
					print('3\n%d %d %d' % (z, y, x))
					return
				b = x
			(y, z) = (z, x - four)
			four *= 2
	if b == mi:
		print('1\n%d' % mi)
		return
	d = 1
	while b - d not in s:
		d *= 2
	print('2\n%d %d' % (b - d, b))
main()


from bisect import bisect as bs
t = [0] * int(input())
a = sorted(map(int, input().split()))
g = lambda x: a[bs(a, x) - 1] == x
for (_, x) in enumerate(a):
	for i in range(31):
		l = x - 2 ** i
		r = x + 2 ** i
		t[_] = max(t[_], g(l) + g(r))
m = max(t)
if m == 2:
	print(3)
	_ = t.index(2)
	x = a[_]
	for i in range(31):
		l = x - 2 ** i
		r = x + 2 ** i
		if g(l) and g(r):
			print(l, x, r)
			return
if m == 1:
	print(2)
	_ = t.index(1)
	x = a[_]
	for i in range(31):
		l = x - 2 ** i
		r = x + 2 ** i
		if g(l):
			print(l, x)
			return
		if g(r):
			print(x, r)
			return
print(1)
print(a[0])


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	n = ii()
	arr = li()
	sett = set(arr)
	ans = [arr[0]]
	flag = 0
	for x in range(31):
		for i in arr:
			if i - 2 ** x in sett and i + 2 ** x in sett:
				ans = [i - 2 ** x, i, i + 2 ** x]
				flag = 1
				break
			elif i - 2 ** x in sett:
				ans = [i - 2 ** x, i]
			elif i + 2 ** x in sett:
				ans = [i, i + 2 ** x]
		if flag:
			break
	print(len(ans))
	print(*ans)
main()


import sys
n = int(input())
L = sorted(list(map(int, input().split())))
dic = dict()
ss = set(L)
ans = [L[0]]
for i in range(n):
	for j in range(32):
		t = (1 << j) + L[i]
		if t in ss:
			ans = [L[i], t]
			if t + (1 << j) in ss:
				print(3)
				print(L[i], t, t + (1 << j))
				sys.exit()
print(len(ans))
for i in ans:
	print(i, end=' ')
print()


N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
import bisect as bi
P = []
for i in range(0, 31):
	P.append(2 ** i)
max = 1
saved = [L[0]]
for i in range(0, N):
	for j in range(0, 31):
		if bi.bisect_left(L, L[i] + P[j]) != bi.bisect_right(L, L[i] + P[j]):
			max = 2
			saved = [L[i], L[i] + P[j]]
			if bi.bisect_left(L, L[i] + 2 * P[j]) != bi.bisect_right(L, L[i] + 2 * P[j]):
				print(3)
				print(L[i], L[i] + P[j], L[i] + 2 * P[j])
				exit()
print(max)
print(*saved)


def is_power2(num):
	return num & num - 1 == 0

def maybeAdd(dot, peers):
	for peer in peers:
		if not is_power2(abs(dot - peer)):
			return False
	peers.append(dot)
n = int(input())
dots = list(map(int, input().split()))
m = min(dots)
M = max(dots)
l = {}
for dot in dots:
	l[dot] = True
ans = []
att = []
for dot in dots:
	att = [dot]
	maxpow = max(abs(dot - m), abs(dot - M)).bit_length()
	diff = 1
	for pow in range(maxpow):
		if dot - diff in l:
			maybeAdd(dot - diff, att)
		if dot + diff in l:
			maybeAdd(dot + diff, att)
		diff *= 2
	if len(att) > len(ans):
		ans = att
print(len(ans))
print(*ans)


import os
import io
import sys
from collections import Counter, defaultdict
import math
import random
import heapq as hq
from functools import reduce, cmp_to_key
from collections import deque
import threading
import bisect

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
n = iinput()
a = rlinput()
d = defaultdict()
for i in a:
	d[i] = 1
flag = -1
ans = []
for i in a:
	b = False
	for j in range(31):
		want1 = i + int(pow(2, j))
		want2 = i - int(pow(2, j))
		if want1 in d and want2 in d:
			flag = 3
			ans = [want1, want2, i]
			b = True
			break
		else:
			if want1 in d:
				flag = 2
				ans = [want1, i]
			if want2 in d:
				flag = 2
				ans = [want2, i]
	if b:
		break
if flag != -1:
	print(flag)
	print(*ans)
else:
	print(1)
	print(a[0])


n = int(input())
X = list(map(int, input().split()))
if n == 1:
	print(1)
	print(X[0])
	exit()
table = [0] * 32
table[0] = 1
for i in range(1, 32):
	table[i] = 2 * table[i - 1]
S = set(X)
l = -1
for x in X:
	for d in range(32):
		temp = [x]
		if x - table[d] in S:
			temp.append(x - table[d])
		if x + table[d] in S:
			temp.append(x + table[d])
		if len(temp) >= l:
			l = len(temp)
			ans = temp
print(len(ans))
print(*ans)


import math
n = int(input())
xs = sorted(map(int, input().split()))
pool = set(xs)
power_max = int(math.log(xs[-1] - xs[0] + 1, 2))
ans = (xs[0],)
for p in range(power_max + 1):
	for x in xs:
		if x + 2 ** p in pool:
			ans = (x, x + 2 ** p)
			if x + 2 * 2 ** p in pool:
				print(3)
				print(x, x + 2 ** p, x + 2 * 2 ** p)
				exit(0)
print(len(ans))
print(*ans, sep=' ')


def read_numbers():
	return (int(s) for s in input().strip().split(' '))
keys = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]

def main():
	_ = input()
	dots = set(read_numbers())
	max_res = []
	for dot in dots:
		for dist in keys:
			res = [dot]
			d1 = dot - dist
			d2 = dot + dist
			if d1 in dots:
				res.append(d1)
			if d2 in dots:
				res.append(d2)
			if len(res) > len(max_res):
				max_res = res
			if len(max_res) == 3:
				print(len(max_res))
				print(' '.join((str(n) for n in max_res)))
				return
	print(len(max_res))
	print(' '.join((str(n) for n in max_res)))

def __starting_point():
	main()
__starting_point()


import sys

def isPow2(num):
	return num and (not num & num - 1)

def main():
	Num_Points = int(input())
	Points = set(map(int, input().split()))
	Max_Num = max(Points)
	Max_Size = 1
	for (i, num) in enumerate(Points):
		Po2 = 1
		Size_Group = 1
		while num + Po2 <= Max_Num:
			if num + Po2 in Points:
				if num + 2 * Po2 in Points:
					Size_Group = 3
					print('3')
					print(num, num + Po2, num + 2 * Po2)
					return
				else:
					Max_Size = 2
					Result = []
					Result.append(num)
					Result.append(num + Po2)
			Po2 *= 2
	if Max_Size == 2:
		print('2')
		print(*Result)
	else:
		print('1')
		print(Max_Num)
main()


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
flag = 0
import bisect
for i in range(0, n):
	for j in range(0, 31):
		b = a[i] + 2 ** j
		p = bisect.bisect_left(a, b)
		if p < n:
			if a[p] == b:
				a1 = a[i]
				b1 = b
				flag = 100
				c = a[i] + 2 * 2 ** j
				q = bisect.bisect_left(a, c)
				if q < n:
					if a[q] == c:
						flag = 200
						break
	if flag == 200:
		break
if flag == 0:
	print(1)
	print(a[0])
elif flag == 100:
	print(2)
	print(a1, b1)
else:
	print(3)
	print(a[i], b, c)


from sys import stdin
input = stdin.buffer.readline
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
s = set(arr)
flag = False
for ele in arr:
	for i in range(31):
		if ele - 2 ** i in s and ele + 2 ** i in s:
			ans = [ele, ele - 2 ** i, ele + 2 ** i]
			flag = True
			break
	if flag:
		break
if flag:
	print(3)
	print(*ans)
	exit()
for ele in arr:
	for i in range(31):
		if ele + 2 ** i in s:
			ans = [ele, ele + 2 ** i]
			flag = True
			break
	if flag:
		break
if flag:
	print(2)
	print(*ans)
else:
	print(1)
	print(arr[0])


import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def solve(N, A):
	wc = collections.Counter(A)
	vals = set(wc.keys())
	(minv, maxv) = (min(vals), max(vals))
	ans = 0
	selected = []
	for v in vals:
		if wc[v] > ans:
			ans = wc[v]
			selected = [v]
		k = 1
		while v + k <= maxv:
			if v + k in vals:
				if v + k * 2 in vals:
					count = wc[v] + wc[v + k] + wc[v + k * 2]
					if count > ans:
						ans = count
						selected = [v, v + k, v + k * 2]
				else:
					count = wc[v] + wc[v + k]
					if count > ans:
						ans = count
						selected = [v, v + k]
			k *= 2
		k = 1
		while v - k >= minv:
			if v - k in vals:
				if v - k * 2 in vals:
					count = wc[v] + wc[v - k] + wc[v - k * 2]
					if count > ans:
						ans = count
						selected = [v, v - k, v - k * 2]
				else:
					count = wc[v] + wc[v - k]
					if count > ans:
						ans = count
						selected = [v, v - k]
			k *= 2
	print(ans)
	print(' '.join([' '.join(map(str, [v] * wc[v])) for v in selected]))
N = int(input())
A = [int(x) for x in input().split()]
solve(N, A)


def main():
	input()
	s = set(map(int, input().split()))
	b = ma = max(s)
	for x in s:
		y = x + 1
		while y <= ma:
			z = y * 2 - x
			if y in s:
				b = x
				if z in s:
					print('3\n%d %d %d' % (x, y, z))
					return
			y = z
	if b == ma:
		print('1\n%d' % ma)
		return
	x = 1
	while b + x not in s:
		x *= 2
	print('2\n%d %d' % (b, b + x))
main()


n = int(input())
n1 = input().split()
n2 = []
s1 = set()
for x in n1:
	n2.append(int(x))
	s1.add(int(x))
n2.sort()
maxy = n2[len(n2) - 1] - n2[0]
count = 0
num = 1
while num < maxy:
	num = num * 2
	count = count + 1
flag = 0
base0 = 0
base1 = 0
base2 = -1
cflag = 0
for x in n2:
	for z in range(0, count + 1):
		if x + 2 ** z in s1:
			if flag == 0:
				flag = 1
				base0 = x
				base1 = x + 2 ** z
			if x + 2 ** (z + 1) in s1:
				cflag = 1
				base0 = x
				base1 = x + 2 ** z
				base2 = x + 2 ** (z + 1)
				break
	if cflag == 1:
		break
if cflag == 1:
	s = '3\n' + str(base0) + ' ' + str(base1) + ' ' + str(base2)
	print(s)
if cflag == 0 and flag == 1:
	s = '2\n' + str(base0) + ' ' + str(base1)
	print(s)
if cflag == 0 and flag == 0:
	s = '1\n' + str(n2[0])
	print(s)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
N = int(input())
s = list(map(int, input().split()))
s.sort()
d = {}
for x in s:
	d[x] = 1
i = 1
ans = []
while i < 1e+18:
	for x in s:
		t = []
		if d.get(x + i, 0) == 1:
			t = [x, x + i]
		if d.get(x + 2 * i, 0) == 1:
			t.append(x + 2 * i)
		if len(t) > len(ans):
			ans = t
		if len(ans) == 3:
			print(3)
			print(*ans)
			exit(0)
	i *= 2
if len(ans) < 2:
	ans = [s[0]]
print(len(ans))
print(*ans)


def f():
	k = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	d = {}
	for (i, j) in enumerate(l):
		d[j] = i
	n = 1
	s = ''
	while l[0] + n <= l[-1]:
		for i in l:
			if i + n in d and i + 2 * n in d:
				print(3)
				print(i, i + n, i + 2 * n)
				return
			elif i + n in d:
				s = str(i) + ' ' + str(i + n)
		n = n * 2
	if s == '':
		print(1, l[0], sep='\n')
	else:
		print(2, s, sep='\n')
f()


a = int(input())
l = list(map(int, input().split()))
k = set(l)
power2 = [2 ** i for i in range(31)]
ans = 0
for i in range(len(l)):
	for j in power2:
		left = l[i] - j
		right = l[i] + j
		if left in k and right in k:
			print(3)
			print(left, l[i], right)
			exit(0)
		if ans == 0:
			if left in k:
				x = left
				y = l[i]
				ans = 1
if ans == 1:
	print(2)
	print(x, y)
else:
	print(1)
	print(l[0])


import sys

def solve(io):
	N = io.readInt()
	X = io.readIntArray(N)
	has = set(X)
	best = (X[0],)
	for v in X:
		for b in range(0, 31):
			p = 1 << b
			a = v + p
			if a in has:
				if len(best) < 2:
					best = (v, a)
				b = a + p
				if b in has and len(best) < 3:
					best = (v, a, b)
					break
	io.println(len(best))
	io.printlnArray(best)

class IO:
	input = None
	output = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, inputStream, outputStream):
		self.input = inputStream
		self.output = outputStream

	def readToBuffer(self):
		self.raw = self.input.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def readString(self):
		while self.pos == len(self.buf):
			self.readToBuffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def readInt(self):
		return int(self.readString())

	def readFloat(self):
		return float(self.readString())

	def readStringArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readString())
		return arr

	def readIntArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readInt())
		return arr

	def readFloatArray(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.readFloat())
		return arr

	def readLine(self):
		while self.pos == len(self.buf):
			self.readToBuffer()
		if self.pos > 0:
			raise ValueError('Cannot call readline in the middle of a line.')
		return self.raw

	def print(self, s):
		self.output.write(str(s))

	def println(self, s):
		self.print(s)
		self.print('\n')

	def printlnArray(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flushOutput(self):
		self.output.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flushOutput()


n = int(input())
arr = sorted(list(map(int, input().split())))
d = {}
for i in range(n):
	d[arr[i]] = i
ans = 0
ans_diff = 0
curr = 1
while curr <= 3 * 10 ** 9:
	markings = [0 for _ in range(n)]
	for t in range(n):
		if markings[t] == 0:
			count = 1
			x = t
			while arr[x] + curr in d.keys() and count < 3:
				x = d[arr[x] + curr]
				count += 1
			if count > ans:
				ans = max(ans, count)
				ans_diff = [t, curr]
	curr = curr * 2
print(min(3, ans))
count = 0
while count < ans and count < 3:
	print(arr[ans_diff[0]] + count * ans_diff[1], end=' ')
	count += 1
print('')


n = int(input())
points = set((int(x) for x in input().strip().split()))
powers = [2 ** i for i in range(31)]
for point in points:
	for power in powers:
		if point + power in points and point + power + power in points:
			print(3)
			print(point, point + power, point + power + power)
			exit()
for point in points:
	for power in powers:
		if point + power in points:
			print(2)
			print(point, point + power)
			exit()
print(1)
print(points.pop())


n = int(input())
a = [int(s) for s in input().split(' ')]
best_m = 1
best_res = []
best_res.append(a[0])
powers = []
for i in range(31):
	powers.append(2 ** i)
s = set()
for i in range(n):
	s.add(a[i])
for i in range(n):
	if best_m == 3:
		break
	x = a[i]
	for p in range(31):
		d = powers[p]
		if x - d in s and x + d in s:
			best_m = 3
			best_res = [x - d, x, x + d]
			break
		if best_m >= 2:
			continue
		if x - d in s:
			best_m = 2
			best_res = [x - d, x]
			continue
		if x + d in s:
			best_m = 2
			best_res = [x, x + d]
			continue
print(best_m)
print(' '.join([str(x) for x in best_res]))


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
S = set(A)
mx = 0
ans = []
for (i, a) in enumerate(A):
	for j in range(32):
		tmp = [a]
		k = 2 ** j
		if a + k in S:
			tmp.append(a + k)
		if a - k in S:
			tmp.append(a - k)
		if len(tmp) > mx:
			mx = len(tmp)
			ans = tmp
print(len(ans))
print(*ans)


n = int(input())
a = set(map(int, input().split()))
b = max(a)
p = 0
for x in a:
	d = 1
	while x + d <= b:
		y = x + d
		if y in a:
			p = (x, y)
			if y + d in a:
				print(3)
				print(x, y, y + d)
				exit()
		d *= 2
if p:
	print(2)
	print(*p)
else:
	print('1\n' + str(b))


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d1 = defaultdict()
for j in range(n):
	d1[arr[j]] = 1
(flag, ans) = (0, 0)
been = 0
for i in arr:
	for j in range(31):
		a = i + int(pow(2, j))
		b = i - int(pow(2, j))
		if a in d1 and b in d1:
			ans = 3
			fin = [a, i, b]
			flag = 1
			been = 1
			break
		elif a in d1:
			ans = 2
			fin = [a, i]
			been = 1
		elif b in d1:
			ans = 2
			fin = [i, b]
			been = 1
	if flag == 1:
		break
if been == 0:
	print(1)
	print(arr[0])
else:
	print(ans)
	print(' '.join(map(str, fin)))


def pows2(n):
	p2 = 1
	while p2 <= n:
		yield p2
		p2 <<= 1

def maxseq(l, d):
	prev = -float('inf')
	best = []
	curr = []
	for v in l:
		if v - prev != d:
			curr = []
		curr.append(v)
		prev = v
		if len(best) < len(curr):
			best = curr
	return best
n = int(input())
x = sorted(map(int, input().split()))
ans = []
for p2 in pows2(max(x) - min(x) + 1):
	y = {}
	for v in x:
		vs = v % p2
		if vs not in y or len(y[vs]) >= 3 or v - y[vs][-1] != p2:
			y[vs] = []
		y[vs].append(v)
		ans = max(ans, y[vs], key=len)
print(len(ans))
print(*ans)


n = int(input())
s = set(map(int, input().split()))
ans = 0
t = {}
for i in s:
	for x in range(32):
		j = 2 ** x
		tmp = 1
		tmpt = {i}
		if i - j in s:
			tmp += 1
			tmpt.add(i - j)
		if i + j in s:
			tmp += 1
			tmpt.add(i + j)
		if tmp > ans:
			ans = tmp
			t = tmpt
print(ans)
print(' '.join(map(str, t)))


n = int(input())
x = list(map(int, input().split()))
y = set(x)
ans = [x[0]]
for d in range(31):
	e = 2 ** d
	for i in range(n):
		if x[i] - e in y and x[i] + e in y:
			print(3)
			print(x[i] - e, x[i], x[i] + e)
			exit()
		elif x[i] - e in y:
			ans = [x[i], x[i] - e]
		elif x[i] + e in y:
			ans = [x[i], x[i] + e]
if len(ans) == 2:
	print(2)
	print(ans[0], ans[1])
else:
	print(1)
	print(ans[0])


n = int(input())
ar = set(map(int, input().split()))
Max = max(ar)
ans = ()
flag = 0
for i in ar:
	j = 1
	while i + j <= Max:
		if i + j in ar:
			ans = (i, i + j)
			flag = 1
			if i + 2 * j in ar:
				print('3')
				print(i, i + j, i + 2 * j)
				return
		j *= 2
if flag == 1:
	print('2')
	print(*ans)
else:
	print('1')
	print(Max)


import itertools

def powmod(x, p, m):
	if p <= 0:
		return 1
	if p <= 1:
		return x % m
	return powmod(x * x % m, p // 2, m) * (x % m) ** (p % 2) % m

def to_basex(num, x):
	while num > 0:
		yield (num % x)
		num //= x

def from_basex(it, x):
	ret = 0
	p = 1
	for d in it:
		ret += d * p
		p *= x
	return ret

def core():
	n = int(input())
	xs = [int(x) for x in input().split()]
	xs.sort()
	sxs = set(xs)
	ans = []
	for x in xs:
		cand = [x]
		m = 1
		while True:
			y = x + m
			if y > xs[-1]:
				break
			if y in sxs:
				if len(cand) == 2 and cand[1] - cand[0] == y - cand[1]:
					cand.append(y)
					return cand
				cand = [cand[0], y]
			m *= 2
		if len(cand) > len(ans):
			ans = cand
	return ans
ans = core()
print(len(ans))
print(*ans)


from collections import defaultdict
(n, a) = (int(input()), [int(x) for x in input().split()])
pow2 = [1 << i for i in range(32)]
mp = defaultdict()
for x in a:
	mp[x] = 1
mxSiz = 1
ans = [a[0]]
for x in a:
	for y in pow2:
		if x - y in mp and x + y in mp:
			mxSiz = 3
			ans = [x - y, x, x + y]
		if x - y in mp and 2 > mxSiz:
			mxSiz = 2
			ans = [x - y, x]
print(mxSiz)
print(*ans)


n = int(input())
an = list(map(int, input().strip().split(' ')))
an_set = set(an)
flag = False
flag_3 = False
s = [1 << i for i in range(31)]
for i in range(n):
	for j in s:
		a1 = an[i]
		a2 = a1 + j
		a3 = a1 - j
		if a2 in an_set and a3 in an_set:
			print(3)
			print(a1, a2, a3)
			exit(0)
		if not flag:
			if a2 in an_set:
				flag = True
				x1 = a1
				x2 = a2
if flag:
	print(2)
	print(x1, x2)
else:
	print(1)
	print(an[0])


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (fast, lambda : map(int, z().split()))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer, end='\n'):
	stdout.write(str(answer) + end)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
n = int(z())
arr = set(zz())

def solve():
	for i in arr:
		for k in range(31):
			if i - (1 << k) in arr and i + (1 << k) in arr:
				return [i - (1 << k), i, i + (1 << k)]
	for i in arr:
		for k in range(31):
			if i + (1 << k) in arr:
				return [i, i + (1 << k)]
	for i in arr:
		return [i]
lst = solve()
print(len(lst))
for i in lst:
	output(i, ' ')


n = input()
a = set(map(int, input().split(' ')))
Min = min(a)
Max = max(a)
for i in range(31):
	delta = 1 << i
	for a1 in a:
		if a1 + delta in a and a1 + 2 * delta in a:
			print('3')
			print(a1, a1 + delta, a1 + delta * 2, end=' ')
			exit()
for i in range(31):
	delta = 1 << i
	for a1 in a:
		if a1 + delta in a:
			print('2')
			print(a1, a1 + delta, end=' ')
			exit()
print('1')
for a1 in a:
	print(a1)
	exit()


import sys
import bisect
import math as mt
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	mul = 1
	d = {}
	for i in l:
		d[i] = 1
	maxi = 2 * 10 ** 9
	ans = 1
	(a1, a2, a3) = (0, 0, 0)
	ch = 0
	for i in range(n):
		mul = 1
		while mul <= maxi and ch == 0:
			ans1 = 1
			if d.get(l[i] + mul, -1) != -1:
				ans1 += 1
				a1 = l[i]
				a2 = l[i] + mul
				if d.get(l[i] + 2 * mul, -1) != -1:
					ans1 += 1
					a3 = l[i] + 2 * mul
					ch = 1
			ans = max(ans, ans1)
			if ch:
				break
			mul *= 2
	if ans == 1:
		print(1)
		print(l[0])
	elif ans == 2:
		print(2)
		print(a1, a2)
	else:
		print(3)
		print(a1, a2, a3)


input()
arr = set(map(int, input().split()))
best = (0, [])
for x in arr:
	best = max(best, (1, [x]))
	for i in range(33):
		if x + (1 << i) in arr:
			best = max(best, (2, [x, x + (1 << i)]))
			if x + (2 << i) in arr:
				best = max(best, (3, [x, x + (1 << i), x + (2 << i)]))
				break
print(best[0])
print(*best[1])


import sys
input = sys.stdin.readline
n = int(input())
x = list(map(int, input().split()))
x.sort()
sx = set(x)
k = 1
ml = 1
ans = [x[0]]
for j in range(31):
	for xx in x:
		if xx - k in sx:
			if ml == 1:
				ml = 2
				ans = [xx - k, xx]
		if xx + k in sx:
			if ml == 1:
				ml = 2
				ans = [xx, xx + k]
		if xx - k in sx and xx + k in sx and (ml <= 2):
			ml = 3
			ans = [xx - k, xx, xx + k]
	k *= 2
print(ml)
print(*ans)


def main():
	t = int(input())
	a = [int(x) for x in input().split()]
	p2 = [2 ** i for i in range(32)]
	dic = {}
	for e in a:
		dic[e] = 1
	a.sort()
	ans = []
	for i in a:
		for j in p2:
			if dic.get(i + j):
				if not ans:
					ans = [i, i + j]
				if dic.get(i + j * 2):
					print(3)
					print(i, i + j, i + j * 2)
					return
	if ans:
		print(2)
		print(ans[0], ans[1])
	else:
		print(1)
		print(a[0])

def __starting_point():
	main()
__starting_point()


import io
import os
from collections import defaultdict
from sys import stdin, stdout
input = stdin.readline

def main():
	n = int(input())
	a = sorted(map(int, input().split()))
	s = set(a)
	res = []
	pow2 = [2 ** i for i in range(0, 31)]
	for val in a:
		for p in pow2:
			if val + p in s and val + 2 * p in s:
				res.append(val)
				res.append(val + p)
				res.append(val + 2 * p)
				break
		if res:
			break
	if not res:
		for val in a:
			for p in pow2:
				if val + p in s:
					res.append(val)
					res.append(val + p)
					break
			if res:
				break
	if not res:
		res.append(a[0])
	print(len(res))
	print(*res)
main()


n = int(input())
arr = list(map(int, input().split()))
s = set(arr)
maxi = 0
(p_count, m_count) = (0, 0)
(a, b, c) = (0, 0, 0)
for i in range(31):
	for j in range(n):
		(count, p_count, m_count) = (1, 0, 0)
		if arr[j] + (1 << i) in s:
			p_count += 1
			count += 1
		if arr[j] - (1 << i) in s:
			m_count += 1
			count += 1
		if maxi < count:
			maxi = count
			a = arr[j]
			if maxi == 2 and p_count == 1:
				b = arr[j] + (1 << i)
			if maxi == 2 and m_count == 1:
				b = arr[j] - (1 << i)
			if maxi == 3:
				(b, c) = (arr[j] + (1 << i), arr[j] - (1 << i))
print(maxi)
if maxi == 1:
	print(a)
if maxi == 2:
	print(a, b)
if maxi == 3:
	print(a, b, c)


import sys

def input():
	return sys.stdin.readline().strip()

def input_l():
	return map(int, input().split())

def input_t():
	return tuple(input_l())

def rt():
	return (int(i) for i in input().strip().split())

def main():
	s2t = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]
	input()
	q = set(rt())
	w = []
	for i in q:
		for v in s2t:
			r = [i]
			a = i - v
			s = i + v
			le = len(w)
			if a in q:
				r.append(a)
			if s in q:
				r.append(s)
			if len(r) > le:
				w = r
			if le == 3:
				print(le)
				print(*w)
				return
	print(len(w))
	print(*w)
main()


n = int(input())
s = set(map(int, input().split()))
m = max(s)
ans = [m]
for x in s:
	i = 1
	while x + i <= m:
		y = x + i
		if y in s:
			ans = [x, y]
			if y + i in s:
				print(3)
				print(x, y, y + i)
				exit()
		i *= 2
print(len(ans))
print(*ans)


import sys
import math
from collections import defaultdict
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
vis = defaultdict(int)
(ans, num) = (1, arr[0])
for i in range(n):
	vis[arr[i]] = 1
x = max(arr)
dif = -1
for i in range(n):
	for k in range(31):
		if arr[i] + (1 << k) in vis and arr[i] + (1 << k + 1) in vis:
			cnt = 3
			if cnt > ans:
				ans = cnt
				num = arr[i]
				dif = 1 << k
		if arr[i] + (1 << k) in vis:
			cnt = 2
			if cnt > ans:
				ans = cnt
				num = arr[i]
				dif = 1 << k
if ans == 3:
	res = [num, num + dif, num + 2 * dif]
if ans == 2:
	res = [num, num + dif]
if ans == 1:
	res = [num]
print(ans)
print(*res)


I = lambda : list(map(int, input().split()))
(n,) = I()
s = list(set(I()))
s.sort()
f = {}
for i in set(s):
	f[i] = 1
i = 1
ans = [s[0]]
while i < 1e+18:
	for x in s:
		t = []
		if f.get(x + i):
			t = [x, x + i]
		if f.get(x + 2 * i):
			t.append(x + 2 * i)
		if len(t) > len(ans):
			ans = t
		if len(ans) == 3:
			print(3)
			print(*ans)
			exit()
	i *= 2
print(len(ans))
print(*ans)


import sys
input = sys.stdin.readline
n = int(input())
ar = list(map(int, input().split()))
ar.sort()
se = set(ar)
li = []
st = 1
for i in range(32):
	li.append(st)
	st <<= 1
ans = 1
br = [ar[0]]
for i in ar:
	for j in li:
		if i + j in se:
			if ans < 2:
				ans = 2
				br = [i, i + j]
			if i + 2 * j in se:
				if ans < 3:
					ans = 3
					br = [i, i + j, i + 2 * j]
print(ans)
print(*br)