### Sticks

#### Description:

Chef and his little brother are playing with sticks. They have total N sticks. Length of i-th stick is Ai. 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 Chefs brother can make. Chefs 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 test-cases. 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 space-separated integers A1, A2, ..., AN 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 its impossible to form any rectangle using the available sticks. Constraints 1 <= T <= 100 1 <= N <= 103 1 <= sum of Ns over all test-cases in a single test file <= 103 1 <= Ai <= 103 Test Case 1 Input (stdin) 2 4 2 3 1 2 4 1 2 2 3 Expected Output -1 -1 Test Case 2 Input (stdin) 1 7 1 2 3 4 5 6 7 Expected Output -1

#### Program :

#include<stdio.h>

#include<string.h>

int main()

{

int t,i,j,k;

scanf("%d",&t);

for(i=0;i<t;i++)

{

int n,area=1;

scanf("%d",&n);

int arr[n];

for(j=0;j<n;j++){

scanf("%d",&arr[j]);

}

int temp;

for(j=0;j<n-1;j++)

{

for(k=j;k<n;k++)

{

if(arr[j]<arr[k])

{

temp=arr[j];

arr[j]=arr[k];

arr[k]=temp;

}

}

}

int count=0;

area=1;

for(j=0;j<n;j++)

{

if(arr[j]==arr[j+1])

{

count++;

area*=arr[j];

j++;

}

if(count==2)

break;

}

if(count==2)

printf("%d\n",area);

else

printf("-1\n");

}

return 0;

}