Seating Arrangement
Time limit2sMemory limit1024 MB
Given the head counts of K schools, find the largest room size when all students are split as evenly as possible across M rooms.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Statement
Olympiad preparation has many tasks for the jury and organizing committee, such as writing statements, preparing tests, writing solutions, and setting up computers. It is easy to forget to seat the participants in the rooms correctly. This time, the committee wants to use the seats efficiently and plans a compact seating of the schoolchildren into available rooms. A seating is called compact if, for any two different rooms, the numbers of children in them differ by at most one. A member of the jury with extrasensory abilities predicted that students from schools will reach the on-site round. He also predicted that exactly students will come from the -th school (). Many committee members are skeptical of such predictions, but they have a habit of coming true. Assuming the predictions are correct, find the maximum possible number of participants who can be in one room under a compact seating.
Input
The first line contains two integers and , the number of rooms and the number of schools (, ). The second line contains integers separated by spaces ().
Output
Print one integer, the maximum number of people in one room under a compact seating.
Hint
In the first test, there is only one compact seating: each of the two rooms gets 7 people.