Sticks

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef and his little brother are playing with sticks. They have total N sticks. Length of ith stick is A_{i}. Chef asks his brother to choose any four sticks and to make a rectangle with those sticks its sides. Chef warns his brother to not to break any of the sticks, he has to use sticks as a whole. Also, he wants that the rectangle formed should have the maximum possible area among all the rectangles that Chef's brother can make.
Chef's little brother takes this challenge up and overcomes it. Can you also do so? That is, you have to tell whether it is even possible to create a rectangle? If yes, then you have to tell the maximum possible area of rectangle.
Input
The first line contains a single integer T denoting the number of testcases. T test cases follow.
The first line of each test case contains a single integer N denoting the number of sticks.
The second line of each test case contains N spaceseparated integers A_{1}, A_{2}, ..., A_{N} denoting the lengths of sticks.
Output
For each test case, output a single line containing an integer representing the maximum possible area for rectangle or 1 if it's impossible to form any rectangle using the available sticks.
Constraints
 1 ≤ T ≤ 100
 1 ≤ N ≤ 10^{3}
 1 ≤ sum of N's over all testcases in a single test file ≤ 10^{3}
 1 ≤ A_{i} ≤ 10^{3}
Example
Input: 2 5 1 2 3 1 2 4 1 2 2 3 Output: 2 1
Explanation
Example case 1. Chef's brother can choose sticks of lengths 1, 2, 1, 2. He can create a rectangle with area 1 * 2 = 2.
Example case 2. It's impossible to choose 4 sticks so that they form a rectangle.
Author:  kingofnumbers 
Tags  cook71, greedy, kingofnumbers, simple 
Date Added:  27052016 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 