Christmas is coming, Icy has just received a box of chocolates from her grandparents! The box contains n chocolates. The i-th chocolate has a non-negative integer type a_i.

Icy believes that good things come in pairs. Unfortunately, all types of chocolates are distinct (all a_i are distinct). Icy wants to make at least one pair of chocolates the same type. 

As a result, she asks her grandparents to perform some chocolate exchanges. Before performing any chocolate exchanges, Icy chooses two chocolates with indices x and y (1 ≤ x, y ≤ n, x ≠ y).

In a chocolate exchange, Icy's grandparents choose a non-negative integer k, such that 2^k ≥ a_x, and change the type of the chocolate x from a_x to 2^k - a_x (that is, perform a_x := 2^k - a_x).

The chocolate exchanges will be stopped only when a_x = a_y. Note that other pairs of equal chocolate types do not stop the procedure.

Icy's grandparents are smart, so they would choose the sequence of chocolate exchanges that minimizes the number of exchanges needed. Since Icy likes causing trouble, she wants to maximize the minimum number of exchanges needed by choosing x and y appropriately. She wonders what is the optimal pair (x, y) such that the minimum number of exchanges needed is maximized across all possible choices of (x, y).

Since Icy is not good at math, she hopes that you can help her solve the problem.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of chocolates.

The second line of the input contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).

It is guaranteed that all a_i are distinct.

Output

Output three integers x, y, and m.

x and y are indices of the optimal chocolates to perform exchanges on. Your output must satisfy 1 ≤ x, y ≤ n, x ≠ y.

m is the number of exchanges needed to obtain a_x = a_y. We can show that m ≤ 10^9 for any pair of chocolates.

If there are multiple solutions, output any.

Examples

Input


5
5 6 7 8 9


Output


2 5 5


Input


2
4 8


Output


1 2 2

Note

In the first test case, the minimum number of exchanges needed to exchange a chocolate of type 6 to a chocolate of type 9 is 5. The sequence of exchanges is as follows: 6 → 2 → 0 → 1 → 7 → 9.

In the second test case, the minimum number of exchanges needed to exchange a chocolate of type 4 to a chocolate of type 8 is 2. The sequence of exchanges is as follows: 4 → 0 → 8.

Difficulty: VERY_HARD
Tags: Graph algorithms

Graph traversal

Shortest paths

Implementation

Number theory

Tree algorithms

Dynamic programming

Game theory

Mathematics
Skill types: Dynamic programming

Starter code:

Solutions:
import sys
n = int(sys.stdin.readline())
a = [*map(int, sys.stdin.readline().split())]
p = [1 << i for i in range(32)]

def getp(n):
	return p[(n - 1).bit_length()] - n

def getmax(n):
	(d, n, c, m) = ({a[n]: 0}, a[n], 1, 0)
	while n:
		n = getp(n)
		d[n] = c
		c += 1
	for (idx, i) in enumerate(a):
		(c, j) = (0, i)
		while i not in d:
			i = getp(i)
			c += 1
		if c + d[i] > m:
			m = c + d[i]
			x = idx
	return (x, m)
(x, _) = getmax(0)
(y, m) = getmax(x)
print(x + 1, y + 1, m)


from collections import defaultdict
import sys
import math
input = sys.stdin.readline
flush = sys.stdout.flush
get_int = lambda : int(input().rstrip())
get_arr = lambda : [int(w) for w in input().split()]
from collections import deque
n = get_int()
arr = get_arr()
parents = {}

def process(a):
	if a == 0:
		return
	t = 1
	while t < a:
		t *= 2
	parents[a] = t - a
	process(t - a)
for a in arr:
	process(a)
gr = defaultdict(list)
for v in parents:
	pr = parents[v]
	gr[pr].append(v)

def find_2max(hs):
	(m1, m2) = (hs[0], hs[1])
	if m2 > m1:
		(m1, m2) = (m2, m1)
	for i in range(2, len(hs)):
		m = hs[i]
		if m >= m1:
			(m1, m2) = (m, m1)
		elif m >= m2:
			m2 = m
	return (m1, m2)
heights = {}
ut = {'mxpair': (-1, -1, -1)}

def dfs(node=0):
	hs = []
	h = (0, node)
	for nb in gr[node]:
		(depth, deepest_node) = dfs(nb)
		h = max(h, (depth + 1, deepest_node))
		hs.append(heights[nb])
	if len(hs) >= 2:
		(h1, h2) = find_2max(hs)
		(d1, a) = h1
		(d2, b) = h2
		ut['mxpair'] = max(ut['mxpair'], (d1 + d2 + 2, a, b))
	heights[node] = h
	return h
dfs()
for a in arr:
	(d, deepest_el) = heights[a]
	ut['mxpair'] = max(ut['mxpair'], (d, a, deepest_el))
(d, a, b) = ut['mxpair']
index_of = lambda x: min((i + 1 for i in range(n) if arr[i] == x))
print(index_of(a), index_of(b), d)


import sys
input = sys.stdin.readline
import bisect
from collections import deque
POW2 = [1]
for i in range(60):
	POW2.append(POW2[-1] * 2)
n = int(input())
A = list(map(int, input().split()))
D = dict()
for i in range(n):
	D[A[i]] = i
E = [[] for i in range(n * 20 + 1)]
ind = n
for a in A:
	x = a
	while True:
		k = POW2[bisect.bisect_left(POW2, x)]
		y = k - x
		if not y in D:
			D[y] = ind
			ind += 1
		E[D[y]].append(D[x])
		E[D[x]].append(D[y])
		x = y
		if x == 0:
			break
Q = deque([0])
DIS = [-1] * ind
DIS[0] = 0
while Q:
	x = Q.popleft()
	for to in E[x]:
		if DIS[to] >= 0:
			continue
		else:
			DIS[to] = DIS[x] + 1
			Q.append(to)
MAX = -1
MI = -1
for i in range(ind):
	if DIS[i] > MAX and i < n:
		MAX = DIS[i]
		MI = i
Q = deque([MI])
DIS = [-1] * ind
DIS[MI] = 0
while Q:
	x = Q.popleft()
	for to in E[x]:
		if DIS[to] >= 0:
			continue
		else:
			DIS[to] = DIS[x] + 1
			Q.append(to)
MAX = -1
MI2 = -1
for i in range(ind):
	if DIS[i] > MAX and i < n:
		MAX = DIS[i]
		MI2 = i
print(MI + 1, MI2 + 1, MAX)


from collections import defaultdict
import math
n = int(input())
a = list(map(int, input().split()))
g = defaultdict(set)
for ele in a:
	xx = ele
	while xx:
		vv = math.ceil(math.log(xx, 2))
		bb = pow(2, vv) - xx
		g[bb].add(xx)
		xx = bb
global_max = -1
ans = []

def max_dist(node):
	if len(g[node]) == 0:
		return (0, node)
	global global_max
	global ans
	max1 = max2 = -1
	max_cur1 = -1
	max_cur2 = -1
	for c in g[node]:
		(max_d, cur) = max_dist(c)
		if max_d > max1:
			max2 = max1
			max_cur2 = max_cur1
			max1 = max_d
			max_cur1 = cur
		elif max_d > max2:
			max2 = max_d
			max_cur2 = cur
	if max1 + max2 + 2 > global_max:
		if max2 != -1:
			global_max = max1 + max2 + 2
			ans = [max_cur1, max_cur2]
		else:
			global_max = max1 + max2 + 2
			ans = [max_cur1, node]
	return (max1 + 1, max_cur1)
max_dist(0)
finals = []
for (i, ele) in enumerate(a):
	if ele == ans[0] or ele == ans[1]:
		finals.append(i + 1)
print(finals[0], finals[1], global_max, sep=' ')


from sys import stdin, stdout
from collections import deque
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
a_as_set = {}
for i in range(n):
	a_as_set[a[i]] = i + 1

def downsize(k):
	if k == 0:
		return -1
	temp = 1
	while temp < k:
		temp *= 2
	return temp - k
neighbours = {0: [-1]}
for i in range(n):
	pointer = a[i]
	while pointer not in neighbours or len(neighbours[pointer]) < 2:
		parent = downsize(pointer)
		if pointer in neighbours:
			neighbours[pointer].append(parent)
		else:
			neighbours[pointer] = [parent]
		if parent in neighbours:
			neighbours[parent].append(pointer)
		else:
			neighbours[parent] = [pointer]
		pointer = parent
queue = deque()
queue.append((a[0], 0, -1))
current_max_distance = 0
current_x = a[0]
while len(queue) > 0:
	(v, d, parent) = queue.popleft()
	for w in neighbours[v]:
		if w > -1 and w != parent:
			queue.append((w, d + 1, v))
			if w in a_as_set:
				current_max_distance = d + 1
				current_x = w
queue = deque()
queue.append((current_x, 0, -1))
current_max_distance = 0
current_y = current_x
while len(queue) > 0:
	(v, d, parent) = queue.popleft()
	for w in neighbours[v]:
		if w > -1 and w != parent:
			queue.append((w, d + 1, v))
			if w in a_as_set:
				current_max_distance = d + 1
				current_y = w
stdout.write('{} {} {}\n'.format(a_as_set[current_x], a_as_set[current_y], current_max_distance))