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 os.path
import math
import heapq
import copy
from sys import stdin,stdout
from collections import*
from math import gcd,ceil,floor
mod = int(1e9+7)
##sys.setrecursionlimit(10**8)
##input=sys.stdin.readline

if os.path.exists('Updated prg/Input3d.txt'):
    sys.stdout=open("Updated prg/Output3d.txt","w")
    sys.stdin=open("Updated prg/Input3d.txt","r")
 
def sinp():return input()
def ninp():return int(sinp())
def mapinp():return map(int,sinp().split())
def smapinp():return map(str,sinp().split())
def linp():return list(mapinp())
def sl():return list(sinp().split())
def prnt(a):print(a)
def prntl(a):print(a,end=" ")
def prntlist(l1) : print(*l1)
def power(n): return 1<<n

n=ninp()
a=linp()
result=0
d1=dict()
for i in a:
    for j in range(1,32):
        a1=power(j)
        if a1-i in d1:
            result=result+d1[a1-i]
    if i in d1:
        d1[i]=d1[i]+1
    else:
        d1[i]=1
prnt(result)
