Issue in taking input

I am not able to take input , getting noSuchElement Exception .

Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int ar[]=new int[n];
for(int i=0;i<n;i++){
ar[i]=sc.nextInt();
}

Hi @geeksalokkumar, are you providing the custom input?