No tag edit access

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-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/21/2019 02:03:40 (g1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|