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.
def binarySearch(arr, elem):
	left = 0
	right = len(arr)-1
	while left<=right:
		mid = (left+right)/2
		if arr[mid] == elem:
			return mid+1
		elif mid!=len(arr)-1 and arr[mid]<elem<arr[mid+1]:
			return mid+1
		elif elem>arr[mid]:
			left = mid+1
		else:
			right = mid-1
	if left == 0:
		return 0
	else:
		return len(arr)

# arr = [3,4,8,12]
# res = binarySearch(arr,2)
# print res, len(arr)-res

import math
n = int(raw_input())
arr = [int(x) for x in raw_input().split()]
res = 0
dict_arr = {}
max_num = max(arr)
max_sum = 2*max_num
i = 1
power2 = []
while 2**i <= max_sum:
	power2.append(2**i)
	i+=1

# print power2

for i in range(len(arr)):
	num = arr[i]
	if num in dict_arr:
		dict_arr[num].append(i)
	else:
		dict_arr[num] = [i]

# print dict_arr

for i in range(len(arr)):
	num = arr[i]
	for power_2 in power2:
		if power_2-num in dict_arr:
			#Apply bianry search and find position
			bres = binarySearch(dict_arr[power_2-num],i)
			res+=len(dict_arr[power_2-num])-bres
print res