The computer science mafia, headed of course by the Codefather, have control of the points spreadsheet. The Codefather has the power to transfer points from one person to another, disguising these transactions under the Bets column of the spreadsheet.
The Codefather's daughter is getting married, and he wants to give a gift to his future son-in-law, who happens to be taking Grade Enriched CompSci. Since only the person with the most points can get in this course, the Codefather wants to ensure that his future son-in-law will have strictly more points than anyone else by performing a number of point transfers. However, he's a cautious man (in his business, you have to be), so he follows the following rules:
- None of the transfers will involve his future son-in-law.
- For each pair of people, he will only perform up to one point transfer, though each transfer can involve any number of points.
- A student cannot both give and receive points.
- After all the transfers are completed, no students can have a negative amount of points.
There are students in this course, each with a unique student number from to , inclusive. Student starts off with points. The Codefather's son-in-law is student .
Though the Codefather is a powerful man, he's still wary of the authorities, and wants to remain as inconspicuous as possible. Therefore, he wants to minimize the largest transfers he makes, while still ensuring that his future son-in-law will get (though with some blackmail, this'll go up to anyway).
Input Specification
Line : The integer .
The next lines: Line contains the integer .
Output Specification
If it's possible for the Codefather to observe the rules and give his
future son-in-law more points than anyone else, minimize the largest
point transfer he must make and output it.
Otherwise, output impossible
.
Sample Input
4
500
300
900
100
Sample Output
202
Explanation
The son-in-law only has points, so the Codefather must make student lose at least . However, the other students must also stay strictly below . His best strategy is to transfer points from student to student , and points from student to student . This will result in the following point distribution:
Student :
Student :
Student :
Student :
Comments
Shouldn't the answer for the sample input be 201? Transfer 1 point from S2 to S4, transfer 200 points from S3 to S1, transfer 201 points from S3 to s4.
That breaks the first rule - None of the transfers will involve his future son-in-law.
Sorry, that was actually a typo. I meant to say: transfer 1 point from S2 to S4, transfer 200 points from S3 to S2, transfer 201 points from S3 to s4.
The statement has been edited to include a clarification that was present on WCIPEG but not on DMOJ. The clarification adds a constraint that makes this sequence of events invalid.