LOCJUN17:HHMGN, NZEC Can someone tell why? Code below

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner s = new Scanner(System.in);
int T = s.nextInt();
while(T–>0)
{
int N = s.nextInt();
long S = s.nextInt();
int A[]= new int[N];
for(int i=0;i<N;i++)
{
A[i] = s.nextInt();
}
Arrays.sort(A);
long sum = 0;
int i=0;
for(i=0;i<N;i++)
{
if(sum+(N-i)*A[i]==S)
{
System.out.println(A[i]);
break;
}

	        else
	        sum+=A[i];
	    }
	     if(i==N)
	        System.out.println(-1);
	}
	
}

}

read the question again, you will get your answer :slight_smile:
and your answer will be given after 7 hours :slight_smile: