//assume xs never drops below 1 element as stated in the constraint
intnegCount=0,remove=-1;
Arrays.sort(xs);
for(inti=0;i<xs.length;i++){
intx=xs[i];
if(x<0){
negCount++;
remove=i;//get last negative value's index to be removed
}
}
if(xs.length>1&&remove!=-1&&negCount%2!=0)xs[remove]=0;//if a remove value is found and it's not the only value, and negative count is not even (multiplying will return negative)
BigIntegerresult=BigInteger.ZERO;//initialize big integer since it can get pretty big according to the readme
for(intx:xs){
if(x!=0)
result=result==BigInteger.ZERO?BigInteger.valueOf(x):result.multiply(BigInteger.valueOf(x));//only multiply non zero values; zero values are almost always discardable
}
returnresult.max(BigInteger.valueOf(xs[xs.length-1])).toString();//check if result is smaller than largest value in array (usually for catching 0s that we discarded)