No such element error, while on custom input the output is correct

I have tried to solve a problem using java ; problem code: INQU2101.
When try to run my code on custom input it is giving the desired output but, when I try to run without custom input it shows error.
Also I am facing the same issue for some other questions on codechef.
My code and error message is given below:


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

import java.util.;
import java.lang.

/* Name of the class has to be “Main” only if the class is public. */
public class codechef
public static void main (String[] args) throws java.lang.Exception
// your code goes here
Scanner sc = new Scanner(;
int t = Integer.parseInt(;

	while(t-- > 0)
	    int n = Integer.parseInt(;
	    while(n-- > 0)


Error :