Get correct answer when compiling using custom input , without custom input it is failing

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 Main.main(Main.java:6)

code :

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int []arr = new int[n];
int i = 0;
for(i = 0 ; i < n ; i++) {
arr[i] = sc.nextInt();
}
for(i = 0 ; i < n ; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
boolean result = isSorted(arr,0);
System.out.println(result);
}
public static boolean isSorted(int []arr,int si) {

	if(si == (arr.length-1)){
		System.out.println("index is = " + si );
		return true;
	}
	if(arr[si] > arr[si+1]){
		System.out.println("index is = " + si );
		return false;
	}
	else {
		System.out.println("index is = " + si );
		return isSorted(arr,si+1);
	}
}

}

Hey
it basically means the element u r requesting does not exist. which is true in case of no input .

How to take care of this no input case ?

You dont have to correct it ,the test cases will always have input