Решал через массив, занес все введенные числа в массив и среди них искал максимальное
package com.javarush.task.task05.task0532;
/*
Задача по алгоритмам
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int x = Integer.parseInt(reader.readLine());
int max = 0;
while (x > 0) {
int [] list = new int[x];
for (int i = 0; i<x; i++) {
list[i] = Integer.parseInt(reader.readLine());
max = list[0];
for (int counter = 1; counter < list.length; counter++){
if(max<list[i]){
max=list[i];
list[i]=list[0];
}
}
}
System.out.println(max);
}
}
}