/* 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.RuntimeException
{
// your code goes here
Scanner sc=new Scanner(System.in);
int Test=sc.nextInt();
for(int i=Test;i>0;i–)
{
int N=sc.nextInt();
ArrayList<Integer> al=new ArrayList<Integer>(N);
for(int p=1;p<=N;p++)
{
al.add(p);
}
for(int j=N-1;j>=1;j--)
{
int X=al.get(j);
int Y=al.get(j-1);
int Sol=(X+Y+X*Y)%(1000000007);
al.set(j-1,Sol);
al.remove(j);
}
System.out.println(al.get(0));
}
}
}
it gives me Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Codechef.main(Main.java:14)
it works properly in custom input but fails while submitting