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
import math
import operator as op
from functools import reduce
from bisect import *
from collections import deque

## I/O ##
def read_line():
	return sys.stdin.readline()[:-1]
 
def read_int():
	return int(sys.stdin.readline())
	
def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]
## ##

## ncr ##
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
## ##

## Fenwick Tree ##
N = int(1e6)+10
fenwick = [0]*N

def add(i,x,n):
	while i<n:
		fenwick[i]+=x
		i = i|(i+1)

def fsum(i,n):
	res = 0
	while i>=0:
		res += fenwick[i]
		i = (i&(i+1))-1
	return res

def fsum_range(i,j,n):
	return fsum(j,n)-fsum(i-1,n)
## ##	

## binary search ##
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    if i:
        return i-1
    return -1

def find_le(a, x):
    'Find rightmost value less than or equal to x'
    i = bisect_right(a, x)
    if i:
        return i-1
    return -1

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect_right(a, x)
    if i != len(a):
        return i
    return -1

def find_ge(a, x):
    'Find leftmost item greater than or equal to x'
    i = bisect_left(a, x)
    if i != len(a):
        return i
    return -1

## ##

## Main ##

mod = int(1e9)+7
mod2 = 998244353

# t = read_int()
t = 1
for i in range(t):
	n = read_int()
	a = read_int_line()
	d = {}
	d1 = {}
	for i in range(n):
		if a[i] in d:
			d[a[i]].append(i)
			d1[a[i]] += 1
		else:
			d[a[i]] = [i]
			d1[a[i]] = 1

	ans = 0

	for i in d:
		for k in d[i]:
			for j in range(33):
				v = (1<<j) - i 
				if v in d:
					ind = find_gt(d[v],k)
					if ind==-1:
						continue
					ans += (d1[v]-ind)

	print(ans)

