#C2616. Maximum Positive Revenue

    ID: 45952 Type: Default 1000ms 256MiB

Maximum Positive Revenue

Maximum Positive Revenue

You are given the revenue of a business for n consecutive days in an array where the ith element represents the revenue for the ith day. Your task is to compute the maximum positive revenue that can be obtained by considering any continuous subarray of days. Formally, you need to find

$$\max_{1\le i \le j \le n} \left(\sum_{k=i}^{j} a_k\right)$$

If no positive subarray exists, output 0.

Note: A subarray consists of a contiguous segment of the array.

inputFormat

The first line contains a single integer n that indicates the number of days.

If n > 0, the second line contains n space-separated integers representing the revenue for each day. If n = 0, the second line is omitted.

outputFormat

Output a single integer which is the maximum positive revenue over any continuous subarray of days. If no such subarray exists, output 0.

## sample
7
-3 -2 4 -1 -2 1 5
7