It outputs the max with positives and negatives. I've ran it through another compiler with N = 0 and N= negative, it returns nothing. I can't figure it out.

package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
int n2 = n -1;
int input = 0;
int maximum = Integer.parseInt(reader.readLine());
if (n2>0){
for(; n2>0; n2--){
input = Integer.parseInt(reader.readLine());
if (input > maximum){
maximum = input;
}
}
}
if (n > 0){
System.out.print(maximum);
}
}
}

everything seems to be alright but there is one logical error1.suppose user entered N=0 your program must be terminated but it will wait for second inputHint :read Nif(N>0) { // find maximum }