Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Powers of Two

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given *n* integers *a*_{1}, *a*_{2}, ..., *a*_{n}. Find the number of pairs of indexes *i*, *j* (*i* < *j*) that *a*_{i} + *a*_{j} is a power of 2 (i. e. some integer *x* exists so that *a*_{i} + *a*_{j} = 2^{x}).

Input

The first line contains the single positive integer *n* (1 ≤ *n* ≤ 10^{5}) — the number of integers.

The second line contains *n* positive integers *a*_{1}, *a*_{2}, ..., *a*_{n} (1 ≤ *a*_{i} ≤ 10^{9}).

Output

Print the number of pairs of indexes *i*, *j* (*i* < *j*) that *a*_{i} + *a*_{j} 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.

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/13/2021 22:38:47 (j3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|