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);
}
}
}