#K67782. Maximum Puzzle Points
Maximum Puzzle Points
Maximum Puzzle Points
You are given a list of integers representing the point value of puzzles. Alex can choose to solve one or more puzzles. The goal is to achieve the maximum possible total points. If there is at least one puzzle with a positive point value, then the answer is defined as the sum of all positive point values, i.e., \( S = \sum_{x>0} x \). Otherwise, if all puzzles have non-positive points, the answer is the maximum value among them.
Formally, let \( P = [p_1, p_2, \dots, p_n] \) be the list of puzzle points. Then, the maximum points \( M \) can be computed as:
[ M = \begin{cases} \sum_{i=1}^{n} \max(p_i, 0) & \text{if } \sum_{i=1}^{n} \max(p_i, 0) > 0, \ \max_{1 \le i \le n} p_i & \text{otherwise.} \end{cases} ]
You need to write a program that reads the input from standard input (stdin) and prints the result to standard output (stdout).
inputFormat
The first line contains a single integer \( n \) representing the number of puzzles.
The second line contains \( n \) space-separated integers, where the \( i^{th} \) integer represents the point value of the \( i^{th} \) puzzle.
outputFormat
Print a single integer representing the maximum points Alex can achieve.
## sample6
-3 5 -1 7 -4 3
15