#P1016. Grand Voting —— 伟大的投票
Grand Voting —— 伟大的投票
Statement
Timothy organized a contest, but it received heavy downvotes. He decided to start manipulating the comments.
This contest has votes, initially set to 0.
There are participants, each with a voting parameter . When it’s their turn to vote:
- If , they cast an upvote, incrementing by 1;
- If , they cast downvote, decrementing by 1.
Timothy can control the voting order of these people. He wants to know the maximum and minimum possible vote count in this contest.
Input
The first line of input contains single integer , representing the number of voters.
The next line of input contains integers , separated by spaces.
Output
Output one line containing two integers separated by a space, representing the maximum and minimum vote count in this contest.
Samples
5
-1 0 1 2 3
5 -5
Note
For example, if you rearrange to , initially . Since , the first voter casts an upvote, making . Similarly, the remaining four voters also satisfy , so all cast upvotes. The final value of is 5, which is the maximum possible.
Conversely, if you rearrange to , then for each voter from left to right, holds, so all cast downvotes, resulting in . This is the minimum possible. Another arrangement such as also leads to .
Related
In following contests: