Getting exception while taking input

i am getting problem from compiler while taking input from scanner it is throwing me no element Exception while its working fine in netbeans please have a look :
import java.util.*;
public class Main {
public static void main (String args[]) {

	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();

	int arr[]=new int [n];

	for(int i=0;i<n;i++){

	arr[i]=sc.nextInt();



	}
	for(int i=0;i<n;i++){

		System.out.println(arr[i]);

	}



}

}

Throwing Me No Element Exception

please share code in cb ide