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 io, os
import sys
from atexit import register
from random import randint

DEBUG = False

if not DEBUG:
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

tokens = []
tokens_next = 0


def nextStr():
    global tokens, tokens_next
    while tokens_next >= len(tokens):
        tokens = input().split()
        tokens_next = 0
    tokens_next += 1

    if type(tokens[tokens_next - 1]) == str:
        return tokens[tokens_next - 1]
    return tokens[tokens_next - 1].decode()


def nextInt():
    return int(nextStr())


def nextIntArr(n):
    return [nextInt() for i in range(n)]


def print(s, end='\n'):
    sys.stdout.write((str(s) + end).encode())


def isPowerOf2(n):
    while n % 2 == 0:
        n //= 2
    return n == 1


def bruteforce(a):
    res = 0
    for i in range(len(a)):
        for j in range(i + 1, len(a)):
            if isPowerOf2(a[i] + a[j]):
                res += 1
                break
    return res


def genTestCase():
    n = randint(1, 20)
    return [randint(1, 10**9) for _ in range(n)]


def solve(a):
    powers = [2**i for i in range(50)]

    res = 0
    seen = {}
    for i in a:
        for p in powers:
            res += seen.get(p - i, 0)
        seen[i] = seen.get(i, 0) + 1
    return res


# while True:
#     cur = genTestCase()
#     soln1 = solve(cur)
#     soln2 = bruteforce(cur)
#     if soln1 != soln2:
#         print('### found one')
#         print(' '.join(map(str, cur)))
#         print(f'{soln1} but should be {soln2}')
#         exit(0)

if __name__ == "__main__":
    a = nextIntArr(nextInt())
    print(solve(a))