Maximum binary product of sum pairs

Maximum binary product of sum pairs

Time Limit: 2.0 s

Memory Limit: 512.0 MB

Description

You are given an array \(A\) of \(N\) integers. Your task is to select any two elements (they can be the same element at different positions), calculate their sum, and then calculate the product of all binary digits of this sum. Your goal is to find the maximum product value that can be obtained from any possible pair of elements.

You have to answer multiple testcases.

Input

First line takes an integer \(T\) : number of testcases
First line of each testcase takes an integer \(N\) : number of elements in the array
next line takes \(N\) integers \(A_1,A_2,A_3......A_N\)

\(1 <= T <= 10^4\)
\(2 <= N <= 2*10^5\)
\(1 <= A_i <= 10^8\)

sum of \(N\) over all testcase will not exceed \(2*10^5\)

Output

For each testcase print one integer in a new line : the maximum product value

Sample

Input Output
2
3
1 2 3
4
1 3 5 1
1
0

in testcase 1 :
you can chose first two element and obtain a sum of 3.
the binary representation of 3 is 11. so the final answer is 1*1=1

Information

ID
1175
Difficulty
8
Category
(None)
Tags
(None)
# Submissions
14
Accepted
7
Accepted Ratio
50%
Uploaded By

Related