Output is correct but can't meet the fifth requirement. Please help. Thanks.
package com.codegym.task.task05.task0532;
import java.io.*;
import java.util.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
int maximum = Integer.MIN_VALUE;
while (true) {
String s = reader.readLine();
if (s == null) break;
int a = Integer.parseInt(s);
list.add(a);
for (int i=0;i<list.size();i++) {
if (list.get(i)>maximum)
maximum = list.get(i);
}
}
if (maximum>0)
System.out.println(maximum);
}
}