enter code here
import java.io.;
import java.util.;
class horses{
public static void main(String[] args) throws java.lang.Exception
{
BufferedReader r= null;
try
{
r= new BufferedReader(new InputStreamReader(System.in));
int T= Integer.parseInt(r.readLine()); //no. of test cases
if(T < 1 || T > 10)
System.exit(0);
else
{
for(int i=1; i<=T; i++)
{
int N= Integer.parseInt(r.readLine());//no. of horses
if(N < 2 || N > 5000)
System.exit(0);
else
{
String[] arr= r.readLine().split(" ");
int[] horse_no= new int[arr.length];
int temp, diff;
for (int j=0; j<N; j++)
{
horse_no[j]= Integer.parseInt(arr[j]);
if(horse_no[j]<0)
System.exit(0);
}
Arrays.sort(horse_no);
diff= horse_no[1]-horse_no[0];
for(int j=0; j<N-1; j++)
{
for(int k=j+1; k<N; k++)
{
if(diff>(horse_no[k]-horse_no[j]))
diff= horse_no[k]-horse_no[j];
}
}
System.out.println(diff);
}
}
}
}
catch(IOException e){
e.printStackTrace();
}
finally{
if(r!= null)
r.close();
}
}
}
i have tried everything with this program but my code is still showing an NZEC runtime error, can anyone point out the error…