public static void main(String args[]) throws NumberFormatException, IOException {
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	int sum = 0;
	int counter = 0;
	while(true) {
		int input = Integer.parseInt(reader.readLine());
		if(input == -1) break;
		sum += input;
		counter++;
	}
	System.out.println(sum/counter);
}
The current program is giving me the correct output but I cannot submit it.