At first, I was setting maximum as 0, and telling the program to only increase the maximum if the number was greater than 0. The problem became that when all the numbers are less than 0, nothing happens, the maximum stays at 0. No matter how low I set the maximum, this problem stays. The solution I came up with was to do a 1 time for loop, where the first number (besides n) is declared the maximum, and then it continues with the rest of the code. I really thought this was going to work, and it did actually run, but the output was just
"java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at com.codegym.task.task05.task0532.Solution.main(Solution.java:19)..."
and so on. Can anyone help on this? Thanks

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 maximum = 0;
for (int k = 0; k<1; k++){
maximum = Integer.parseInt(reader.readLine());
}
if (n > 0){
for (int i = 0; i < n; i++){
int a = Integer.parseInt(reader.readLine());
if (a > maximum)
maximum = a;
}
System.out.println(maximum);
}
else
;
//write your code here
}
}