public class Solution { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int maximum = Integer.MIN_VALUE; int k = Integer.parseInt(reader.readLine()); if (k > 0) { for (int a = 1; a < k; a++) { int N = Integer.parseInt(reader.readLine()); if (N > maximum) maximum = N; } if (maximum < k) maximum = k; System.out.println(maximum); } else { System.out.print("Введите положительное число"); } } //напишите тут ваш код }