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 os
import sys

debug = True

if debug and os.path.exists("input.in"):
    input = open("input.in", "r").readline
else:
    debug = False
    input = sys.stdin.readline


def inp():
    return (int(input()))


def inlt():
    return (list(map(int, input().split())))


def insr():
    s = input()
    return (list(s[:len(s) - 1]))


def invr():
    return (map(int, input().split()))


test_count = 1
if (debug):
    test_count = int(input())

for t in range(test_count):
    N = inp()
    A = inlt()
    value_map = {}
    for x in A:
        if x in value_map:
            value_map[x] = value_map[x] + 1
        else:
            value_map[x] = 1
    two_power = []
    curr = 1
    while curr <= 2000000000:
        two_power.append(curr)
        curr *= 2
    # print(two_power)
    # print(value_map)
    total = 0
    for x in value_map.keys():
        x_count = value_map[x]
        for p in two_power:
            if x < p:
                diff = p - x
                if diff >= x and diff in value_map:
                    if diff == x:
                        total += (x_count * (x_count - 1)) // 2
                    else:
                        total += (x_count * value_map[diff])
    print(total)
