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.parseInt(reader.readLine()); int c = 0, m = 0; if (maximum <= 0) { } else if (maximum == 1) { int b = Integer.parseInt(reader.readLine()); System.out.println(b); } else { int z = Integer.parseInt(reader.readLine()); int b = Integer.parseInt(reader.readLine()); int i = Max(z, b); while (c != maximum - 2) { int o = Integer.parseInt(reader.readLine()); //z = Max(maximum, b); //i = i + m; m = Max(i, o); i = m; c++; } System.out.println(m); } //напишите тут ваш код //System.out.println(maximum); } public static int Max(int a, int b) { return a > b ? a : b; } }