eolymp
bolt
Try our new interface for solving problems
Problems

Profit

Profit

The cows have opened a new business, and Farmer John wants to see how well they are doing. The business operates for $n~(1 \le n ≤ 10^5)$ days, and on each $i$-th day, the cows record their net profit $P_i~(-1000 \le P_i \le 1000)$. Farmer John wants to find the maximum profit that the cows have obtained during any consecutive period of time (note that a consecutive period of time can have a length from one day to $n$ days). Help him by writing a program to find the maximum continuous profit. \InputFile The first line contains an integer $n$. Each of the next $n$ lines contains one integer $P_i$. \OutputFile Print the value of the maximum profit obtained during any consecutive period of time. \includegraphics{https://static.e-olymp.com/content/04/0463695b07c2ed42a04efa592ca807fe87d75c26.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
7
-3
4
9
-2
-5
8
-3
Output example #1
14