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.
"""
You are counting the number of times each number appears in the sequence.
Then for each power of 2, p, you look for each number n that appears in the 
sequence to see if p-n is also there. If it is there, then there 
are (p-n)*n pairs you can make from those two numbers, except if p-n=n, 
in which case there are only (n)*(n-1) pairs you can add.
"""
from collections import Counter


n = int(input())
nums = map(int, input().split())

nums = Counter(nums)
powers = [2**p for p in range(1, 32)]

pairs = 0
for num in nums:
    for power in powers:
        pos_num = power - num
        if pos_num in nums:
            if pos_num != num:
                pairs += nums[num] * nums[pos_num]
            else:
                pairs += (nums[num] - 1) * nums[pos_num]

print(pairs // 2)
