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.
from sys import stdin as si
from collections import Counter as c
from math import ceil as ce


class Solution:

    def __init__(self):
        self.td = [1]
        x = 2
        while x < pow(10,9) * 4:
            self.td.append(x)
            x*=2

    def bazinga(self, m):
        ans = 0
        md = c(m)
        #print (md, m)
        for k in md:
            for x in self.td:
                if x > k and x-k in md and x-k!=k:
                    #print (k, x-k)
                    ans += md[k]*md[x-k]
                if x > k and x-k in md and x-k==k:
                    ans += (md[k]*(md[k]-1))
        print (ce(ans/2))


if __name__=='__main__':
    #for i in range(int(si.readline().strip())):
    n = si.readline().strip()
    m = list(map(int, si.readline().strip().split()))
    S = Solution()
    S.bazinga(m)


'''
123456789123456789
276193619183618162
'''