Help me in solving ZCO14003 problem

My issue

I am facing a Runtime Error saying SIGHUP(signal hang-up) when I follow this approach and not sure what the cause is. Please help me resolve this If you are able to find what the cause is.
Thanks!

My code

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

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

/* 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 read = new Scanner(System.in);
	    int length = read.nextInt();
	    int[] arr = new int[length];
	    for(int i=0;i<length;i++){
	        arr[i] = read.nextInt();
	    }
	    Arrays.sort(arr);
	    int min = arr[0];
	    int max = arr[length-1];
	    if(min*length<max)System.out.println(max);
	    else{
	        System.out.println(min*length);
	    }
	}
}

Problem Link: CodeChef: Practical coding for everyone

Hey, the SIGHUP you were getting on running the code was because the sample test cases not populated correctly. If you run and submit now, you will see that it is giving wrong answer, but some test cases are passing.

1 Like

Thanks, mate!