Can anybody understand why my solution doesn't seem to work? I'm missing something and I really don't know what.
Please take a look and leave a comment if you find what's wrong.

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 maximum = Integer.MIN_VALUE;
while(true){
int n = Integer.parseInt(reader.readLine());
if(n <= 0) {
break;
}
int arr[] = new int[n];
for(int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(reader.readLine());
}
maximum = arr[0];
for(int i = 0; i < n; i++) {
if(maximum < arr[i]) {
maximum = arr[i];
}
}
System.out.println(maximum);
}
}
}