В том числе с отрицательными числами
package com.javarush.task.task05.task0532;
/*
Задача по алгоритмам
*/
import java.io.*;
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 N = Integer.parseInt(reader.readLine());
if (N>0) {
for (int i=1; i<N; i++) {
int m = Integer.parseInt(reader.readLine());
if (m > maximum) {
maximum = m;
}
}
if (N > maximum) {maximum = N;}
System.out.println(maximum);
}
//напишите тут ваш код
}
}