Can anyone tell what is wrong with the following Java Code for MVALUE

import java.io.;
import java.util.
;
import java.math.*;
public class Main{
public static void main(String args[])throws IOException
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int n=sc.nextInt();
long a[]=new long[n];
for(int i=0;i<n;i++)
a[i]=sc.nextLong();

        Arrays.sort(a);
		long ans=((long)Math.max(a[0]*a[1]+a[1]-a[0],a[n-2]*a[n-1]+a[n-1]-a[n-2]));
		System.out.println(ans);
		t--;
    }
}

}