#agc029b. [agc029_b]Powers of two
[agc029_b]Powers of two
Problem Statement
Takahashi has balls with positive integers written on them. The integer written on the -th ball is . He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of . Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed.
Here, a positive integer is said to be a power of when it can be written as using some non-negative integer .
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of .
Sample Input 1
3
1 2 3
Sample Output 1
1
We can form one pair whose sum of the written numbers is by pairing the first and third balls. Note that we cannot pair the second ball with itself.
Sample Input 2
5
3 11 14 5 13
Sample Output 2
2