You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer x exists so that ai + aj = 2x).

Input

The first line contains the single positive integer n (1 ≤ n ≤ 105) — the number of integers.

The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2.

Examples

Input

4
7 3 2 1


Output

2


Input

3
1 1 1


Output

3

Note

In the first example the following pairs of indexes include in answer: (1, 4) and (2, 4).

In the second example all pairs of indexes (i, j) (where i < j) include in answer.
import sys
'''
def binarySearch(alist, item):
    first = 0
    last = len(alist)-1
    found = False
    while first<=last and not found:
        midpoint = (first + last)//2
        if alist[midpoint] == item:
            found = True
	    return midpoint
        else:
            if item < alist[midpoint]:
                last = midpoint-1
            else:
               first = midpoint+1
    return -1
'''
file = sys.stdin
cnt = 0
for line in file:
	if not cnt:
		n = int(line)
	else:
		a = [int(i) for i in line.split()]
	cnt+=1	
a.sort()
new = []
occ = []
prev = -1
for item in a:
	if item!=prev:
		new.append(item)
		occ.append(1)
		prev = item
	else:
		occ[-1]+=1

dic = {}
for i in range(len(new)):
	dic[new[i]]=occ[i]

powers = []
for i in range(1, 32):
	curr = 2**i
	powers.append(curr)
	
cnt = 0
length = len(new)
for x in range(length):
	for y in powers:
		if new[x] >= y:
			continue
		curr = y - new[x]
		if curr in dic:
			cnt += dic[curr]*occ[x]
			if curr == new[x]:
				cnt -= occ[x]	
#	new.popleft()
#	occ.popleft()
#	print new		

print cnt/2

